package
0.1.19
Repository: https://github.com/bdchain/gosf.git
Documentation: pkg.go.dev

# Packages

Package access provides access control utils for json rpc.

# Functions

AddCustomizeCORSHeader 添加自定义 CORS 头.
ApplyCORSHeaders add cors headers to the given rw.
DecodeJSON decode bytes to the recv.
DecodeJSONStrict use strict mode to unmarshal message, which won't allow unknown fields.
DecodeRequest decodes given request's body using json format.
EncodeJSON encode given data into the writer.
EncodeResponse encodes data and write to response body.
Extract extract value for the given key.
ExtractHTTPRequestFromCtx extract *http.Request from given context.
HandleCORS handles cors OPTIONS requests, and set required headers for any other request.
HandleError wraps inner HandlerFunc with error handler.
HandlePanic wraps inner HandlerFunc with panic handler.
HandleRequestInfoLogging provides INFO level loggin for a request, including method, uri & elapsed time.
Inject some values into the http.Request's context, and returns the new http.Request.
InjectHTTPRequest injects given *http.Request into context.
InjectRequestID injects an id for each request.
InjectRequestLogger injects given Logger instance into the request's context.
NewCtxKey returns a context key for context injects.
NewMux returns a json mux with given prefix, logger & middlewares.
NewRootMux returns a root json mux, with default middwares.
NewRPCClient 创建 rpc 客户端.
NewRPCErrorWithCode returns a *RPCError wraps the given http StatusCode.
RegisterMux register a jsonrpc mux onto the given std *http.ServeMux, and uses http.DefaultServeMux if stdmux is nil.
RequestID extracts request id from context.
RequestLogger extracts logger instance from request context.
RequestLoggerFromCtx extracts logger instance from request context.

# Constants

RequestIDHeader http header name for req id.

# Structs

CtxKey context key type.
Mux represents a simple multiplexer for jsonrpc requests.
RPCClient jsonrpc client based on http1.1.
RPCError represents a specific rpc call error.

# Type aliases

HandlerFunc is like http.HandlerFunc, but returns an error.
Middleware defines a simple middleware for jsonrpc.