Documentation ¶
Overview ¶
Package middleware provides a middleware interface for ogen.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HookMiddleware ¶
func HookMiddleware[RequestType, ParamsType, ResponseType any]( m Middleware, req Request, unpack func(Parameters) ParamsType, cb func(context.Context, RequestType, ParamsType) (ResponseType, error), ) (r ResponseType, err error)
HookMiddleware is a helper that does ogen request type -> Request type conversion.
NB: this is an internal func, not intended for public use.
Types ¶
type Middleware ¶
Middleware is middleware type.
func ChainMiddlewares ¶
func ChainMiddlewares(m ...Middleware) Middleware
ChainMiddlewares chains middlewares into a single middleware, which will be executed in the order they are passed.
type ParameterKey ¶ added in v0.55.0
type ParameterKey struct { // Name is the name of the parameter. Name string // In is the location of the parameter. In openapi.ParameterLocation }
ParameterKey is a map key for parameters.
type Parameters ¶ added in v0.55.0
type Parameters map[ParameterKey]any
Parameters is a map of parameters.
func (Parameters) Cookie ¶ added in v0.55.0
func (p Parameters) Cookie(name string) (any, bool)
Cookie returns a parameter from the cookie.
func (Parameters) Header ¶ added in v0.55.0
func (p Parameters) Header(name string) (any, bool)
Header returns a parameter from the header.
type Request ¶
type Request struct { // Context is request context. Context context.Context // OperationName is the ogen operation name. It is guaranteed to be unique and not empty. OperationName string // OperationSummary is the ogen operation summary. OperationSummary string // OperationID is the spec operation ID, if any. OperationID string // Body is the operation request body. May be nil, if the operation has not body. Body any // Params is the operation parameters. Params Parameters // Raw is the raw http request. Raw *http.Request }
Request is request context type for middleware.
func (*Request) SetContext ¶ added in v0.77.0
SetContext sets Context in Request.
Click to show internal directories.
Click to hide internal directories.