Documentation ¶
Index ¶
Constants ¶
View Source
const ( // HTTP Header REQUEST_ID_HEADER = "X-Request-Id" USER_ID_HEADER = "X-FOULKON-USER-ID" // Middleware names AUTHENTICATOR_MIDDLEWARE = "AUTHENTICATOR" XREQUESTID_MIDDLEWARE = "XREQUESTID" REQUEST_LOGGER_MIDDLEWARE = "REQUEST-LOGGER" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Middleware ¶
type Middleware interface { // Action to apply to each request Action(next http.Handler) http.Handler // Additional info that middleware use GetInfo(r *http.Request, mc *MiddlewareContext) }
Middleware interface with operations that all middlewares must implement
type MiddlewareContext ¶
type MiddlewareContext struct { // Authenticator middleware UserId string Admin bool // X-Request-Id middleware XRequestId string }
MiddlewareContext struct contains all parameters used in the context of middlewares
type MiddlewareHandler ¶
type MiddlewareHandler struct {
Middlewares map[string]Middleware
}
MiddlewareHandler handles the HTTP request and applies its list of middlewares before calling the API
func (*MiddlewareHandler) GetMiddlewareContext ¶
func (mwh *MiddlewareHandler) GetMiddlewareContext(r *http.Request) *MiddlewareContext
GetMiddlewareContext method retrieves all information about middleware context applied to request
Click to show internal directories.
Click to hide internal directories.