Documentation ¶
Index ¶
- Variables
- func MetricsMiddleware(next natsrouter.NatsCtxHandler) natsrouter.NatsCtxHandler
- func RequestIdFromContext(ctx context.Context) string
- func RequestIdMiddleware(tags ...string) func(next natsrouter.NatsCtxHandler) natsrouter.NatsCtxHandler
- func TokenFromContext(ctx context.Context) string
- type AuthCallback
- type AuthMiddleware
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNotAuthorized = errors.New("not authorized")
View Source
var ErrTokenMissing = errors.New("authorization token not found")
Functions ¶
func MetricsMiddleware ¶
func MetricsMiddleware(next natsrouter.NatsCtxHandler) natsrouter.NatsCtxHandler
Middleware that increments the message count metric
func RequestIdFromContext ¶
Get current request Id from the context
func RequestIdMiddleware ¶
func RequestIdMiddleware(tags ...string) func(next natsrouter.NatsCtxHandler) natsrouter.NatsCtxHandler
An example request id middleware
func TokenFromContext ¶
Get auth token from the context
Types ¶
type AuthCallback ¶
Callback that must return true if authorized, false otherwise
type AuthMiddleware ¶
type AuthMiddleware struct {
// contains filtered or unexported fields
}
func NewAuthMiddleware ¶
func NewAuthMiddleware(cb AuthCallback, tags ...string) *AuthMiddleware
Create a new authentication middleware, with optional header tag(s) If header tag is not defined, it defaults to `authorization`
func (*AuthMiddleware) Auth ¶
func (a *AuthMiddleware) Auth(next natsrouter.NatsCtxHandler) natsrouter.NatsCtxHandler
Authentication middleware function
Click to show internal directories.
Click to hide internal directories.