Documentation ¶
Index ¶
- Variables
- func CreateMetricsMiddleware(metrics *metrics.Metrics) echo.MiddlewareFunc
- func InitOpenAPIFormats()
- func MatchedRoute(ctx echo.Context) string
- func MetricsMiddlewareWithConfig(config *MetricsConfig) echo.MiddlewareFunc
- func NewAuthenticator() openapi3filter.AuthenticationFunc
- func Nooperation() echo.MiddlewareFunc
- func RequestResponseValidator() echo.MiddlewareFunc
- func RequestResponseValidatorWithConfig(config *RequestResponseValidatorConfig) echo.MiddlewareFunc
- func SLogMiddlewareWithConfig(cfg *SLogMiddlewareConfig) echo.MiddlewareFunc
- func SLogRequest(ctx context.Context, err error, method, path string, status int)
- type MetricsConfig
- type RequestResponseValidatorConfig
- type ResponseRecorder
- type SLogMiddlewareConfig
Constants ¶
This section is empty.
Variables ¶
var DefaultNooperation = Nooperation()
DefaultNooperation is a default instance for Nooperation middleware
var DefaultRequestResponseValidatorConfig = RequestResponseValidatorConfig{ Skipper: echo_middleware.DefaultSkipper, ValidateRequest: true, ValidateResponse: false, }
DefaultRequestResponseValidatorConfig is the default RequestResponseValidator middleware config.
Functions ¶
func CreateMetricsMiddleware ¶
func InitOpenAPIFormats ¶
func InitOpenAPIFormats()
InitOpenAPIFormats configure the admited formats in the openapi specification. This function must be called before receive any request. Suggested to call before instantiate the middleware.
func MatchedRoute ¶
func MatchedRoute(ctx echo.Context) string
See: https://github.com/labstack/echo/pull/1502/files This method exist for v5 echo framework
func MetricsMiddlewareWithConfig ¶
func MetricsMiddlewareWithConfig(config *MetricsConfig) echo.MiddlewareFunc
func NewAuthenticator ¶
func NewAuthenticator() openapi3filter.AuthenticationFunc
NewAuthenticator create an authenticator for the public API
func Nooperation ¶
func Nooperation() echo.MiddlewareFunc
Nooperation is a middleware that do nothing. This is useful to decouple middleware initialisation from middleware wiring, so if some middleware is option based on some configuration, we only have to assign this middleware instead of add middlewares in a conditional way.
func RequestResponseValidator ¶
func RequestResponseValidator() echo.MiddlewareFunc
RequestResponseValidator returns a middleware which validates the HTTP response
func RequestResponseValidatorWithConfig ¶
func RequestResponseValidatorWithConfig(config *RequestResponseValidatorConfig) echo.MiddlewareFunc
func SLogMiddlewareWithConfig ¶
func SLogMiddlewareWithConfig(cfg *SLogMiddlewareConfig) echo.MiddlewareFunc
SLogMiddlewareWithConfig create a middleware for logging config provides
Types ¶
type MetricsConfig ¶
type MetricsConfig struct { Skipper echo_middleware.Skipper Metrics *metrics.Metrics }
type RequestResponseValidatorConfig ¶
type RequestResponseValidatorConfig struct { // Skipper defines a function to skip middleware. Skipper echo_middleware.Skipper ValidateRequest bool ValidateResponse bool }
RequestResponseValidatorConfig defines the config for RequestResponseValidator middleware.
type ResponseRecorder ¶
type ResponseRecorder struct {
// contains filtered or unexported fields
}
In order to validate a response, we need to have access to the bytes of the response. The following code allows us to get access to it.
func (*ResponseRecorder) Header ¶
func (r *ResponseRecorder) Header() http.Header
Implements Header of http.ResponseWriter
func (*ResponseRecorder) Write ¶
func (r *ResponseRecorder) Write(p []byte) (n int, err error)
Implements Write of http.ResponseWriter
func (*ResponseRecorder) WriteHeader ¶
func (r *ResponseRecorder) WriteHeader(statusCode int)
Implements WriteHeader of http.ResponseWriter
type SLogMiddlewareConfig ¶
type SLogMiddlewareConfig struct { Skipper middleware.Skipper Log *slog.Logger }
SLogMiddlewareConfig hold the configuration for the echo slog middleware