Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Logger ¶
func Logger() echo.MiddlewareFunc
Logger returns a middleware that logs every request (its method, escaped path and status) with logrus, once it is handled. It must be executed before the middleware Recover, so the panics are logged too. The error returned by the next handler is not handled here: it is returned, to be handled once by the central error handler of echo. The status logged is the one of the response that the error handler will send.
func LoggerWithConfig ¶
func LoggerWithConfig(config LoggerConfig) echo.MiddlewareFunc
LoggerWithConfig returns a Logger middleware (see Logger) with the given configuration.
func RequestMethod ¶ added in v0.33.0
RequestMethod returns the method of the request as logged by the Logger middleware, before the next handlers possibly rewrote it (like a reverse proxy). Like that, every log about the same request uses the same method. It returns the current method of the request when the Logger middleware didn't handle it.
func RequestPath ¶ added in v0.33.0
RequestPath returns the escaped path of the request as logged by the Logger middleware, before the next handlers possibly rewrote it (like a reverse proxy). Like that, every log about the same request uses the same path. It returns the current escaped path of the request when the Logger middleware didn't handle it.
Types ¶
type LoggerConfig ¶
type LoggerConfig struct {
Skipper middleware.Skipper
// BlackListEndpoint is the list of endpoint that you don't want to log with the info level.
// An endpoint is matched when the route registered in echo (like /metrics, /debug/pprof/* or /api/v1/projects/:project) contains one of these values.
// The route is used instead of the URL, as the URL is controlled by the client, who must not be able to change the log level of its requests.
BlackListEndpoint []string
}
type Metrics ¶
type Metrics struct {
// contains filtered or unexported fields
}
Metrics provides a way to monitor an API with a middleware to use
func NewMetrics ¶
func (*Metrics) Collect ¶
func (m *Metrics) Collect(ch chan<- prometheus.Metric)
func (*Metrics) Describe ¶
func (m *Metrics) Describe(ch chan<- *prometheus.Desc)
func (*Metrics) ProcessHTTPRequest ¶
func (m *Metrics) ProcessHTTPRequest(next echo.HandlerFunc) echo.HandlerFunc
ProcessHTTPRequest is an echo middleware. It will intercept all responses. It will increase the metrics that count the number of HTTP request and calculate the time took to respond. It must be executed before the middleware Recover, so the panics are counted too. The error returned by the next handler is returned as is, to be handled by the central error handler of echo. The status code counted is the one of the response that will be sent, resolved from this error.