Categorygithub.com/faabiosr/echo-middleware
modulepackage
0.10.4
Repository: https://github.com/faabiosr/echo-middleware.git
Documentation: pkg.go.dev

# README

Echo Framework - Middlewares

Build Status Codecov branch Go Reference Go Report Card License

Description

echo-middleware is a Go package that provides multiple middleware for Echo Framework.

Requirements

Echo Middlewares requires Go 1.19 or later and Echo Framework v4.

Instalation

Use go get.

$ go get github.com/faabiosr/echo-middleware

Then import the package into your own code:

import "github.com/faabiosr/echo-middleware"

Development

Requirements

  • Install Go

Makefile

# Clean up
$ make clean

# Download project dependencies
$ make configure

# Run tests and generates html coverage file
$ make cover

# Format all go files
$ make fmt

# Run tests
$make test

License

This project is released under the MIT licence. See LICENSE for more details.

# Functions

CharmLog returns a middleware that logs HTTP requests.
CharmLogWithConfig returns a CharmBracelet Log middleware with config.
Logrus returns a middleware that logs HTTP requests.
LogrusWithConfig returns a Logrus middleware with config.
OpenCensus returns a middleware that collect HTTP requests and response metrics.
OpenCensusWithConfig returns a OpenCensus middleware with config.
RequestID returns a middleware that reads or generates a new request id and returns to response, also stores in context.
RequestIDValue returns the value stored in the context, otherwise returns an empty string.
RequestIDWithConfig uses the echo.RequestIDWithConfig under the hood with custom generator and sets the request id in context.
ZapLog returns a middleware that logs HTTP requests.
ZapLogWithConfig returns a Uber ZapLog middleware with config.
ZeroLog returns a middleware that logs HTTP requests.
ZeroLogWithConfig returns a ZeroLog middleware with config.

# Variables

DefaultCharmLogConfig is the default CharmBracelet Log middleware config.
DefaultLogrusConfig is the default Logrus middleware config.
DefaultOpenCensusConfig is the default OpenCensus middleware config.
DefaultRequestIDConfig is the default RequestID middleware config, based on the echo.RequestIDConfig but with uuid generator instead.
DefaultZapLogConfig is the default Uber ZapLog middleware config.
DefaultZeroLogConfig is the default ZeroLog middleware config.
OpenCensusRequestCount counts the HTTP requests started.
OpenCensusRequestCountByMethod counts the HTTP requests by method.
OpenCensusRequestCountByPath counts the HTTP requests by path.
OpenCensusResponseCountByStatusCode counts the HTTP requests by status code.

# Structs

CharmLogConfig defines the config for CharmBracelet Log middleware.
LogrusConfig defines the config for Logrus middleware.
OpenCensusConfig defines the config for OpenCensus middleware.
ZapLogConfig defines the config for Uber ZapLog middleware.
ZeroLogConfig defines the config for ZeroLog middleware.

# Type aliases

RequestIDConfig alias for emw.RequestIDConfig.