Documentation ¶
Overview ¶
Package server provides common extensions (middleware) required for production DRPC servers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LoggingHook ¶
LoggingHook provides a mechanism to extend a message fields just before is submitted.
type Middleware ¶
Middleware elements allow to customize the internal requests processing by the server.
func AuthByToken ¶
func AuthByToken(key string, validator TokenValidator) Middleware
AuthByToken allows to use an external authentication mechanism using bearer tokens as credentials. The token must be present in the request's metadata under `key` and be valid according to the provided `validator`.
func Logging ¶
func Logging(logger xlog.Logger, hook LoggingHook) Middleware
Logging produce output for the processed RPC requests tagged with standard ECS details by default. Fields can be extended by providing a hook function.
func PanicRecovery ¶
func PanicRecovery() Middleware
PanicRecovery allows the server to convert unhandled panic events into an "internal" RPC error. This will prevent the server from crashing if a handler produces a `panic` operation.
func RateLimit ¶
func RateLimit(limit int) Middleware
RateLimit enforce a maximum limit of RPC requests per-second on the server. It is implemented as a `token bucket` instance. More information: https://en.wikipedia.org/wiki/Token_bucket
type TokenValidator ¶
TokenValidator represents an external authentication mechanism used to validate bearer credentials. In case of any error the validation function must return 'false' and the server will return an 'invalid credentials' error message.