middleware

package module
v1.6.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 28, 2023 License: Apache-2.0 Imports: 10 Imported by: 2

README

echo-middleware

This project provides a collection of echo middleware used in API / Web projects.

GitHub Actions status Go Report Card Documentation

License

This code was authored by Mark Wolfe and licensed under the Apache 2.0 license.

Documentation

Index

Constants

View Source
const OriginVerifyHeaderName = "X-Origin-Verify"

Variables

This section is empty.

Functions

func NoCache added in v1.4.0

func NoCache() echo.MiddlewareFunc

NoCache returns a middleware which sets the no cache headers with default configuration.

func NoCacheWithConfig added in v1.4.0

func NoCacheWithConfig(config NoCacheConfig) echo.MiddlewareFunc

NoCacheWithConfig returns a middleware which sets a number of http headers to ensure the resource is not cached.

As per http://wiki.nginx.org/HttpProxyModule - NoCache sets:

Expires: Thu, 01 Jan 1970 00:00:00 UTC
Cache-Control: no-cache, private, max-age=0
X-Accel-Expires: 0
Pragma: no-cache (for HTTP/1.0 proxies/clients)

func OriginVerifierWithConfig added in v1.5.0

func OriginVerifierWithConfig(config OriginVerifierConfig) echo.MiddlewareFunc

OriginVerifierWithConfig returns a middleware which verifies requests include a `X-Origin-Verify` header containing the token configured, requests which fail will be rejected with a 400 bad request status code.

This solution is based on a pattern presented in https://aws.amazon.com/blogs/networking-and-content-delivery/restricting-access-http-api-gateway-lambda-authorizer/ and uses the same header name.

func ZeroLogRequestLog added in v1.1.0

func ZeroLogRequestLog() echo.MiddlewareFunc

ZeroLogRequestLog returns a request logger middleware with default config.

func ZeroLogRequestLogWithConfig added in v1.1.0

func ZeroLogRequestLogWithConfig(config ZeroLogRequestLogConfig) echo.MiddlewareFunc

ZeroLogRequestLogWithConfig returns a request logger middleware with config.

func ZeroLogWithConfig

func ZeroLogWithConfig(cfg ZeroLogConfig) echo.MiddlewareFunc

ZeroLogWithConfig setup and return an echo middleware with zerolog logger available from the context.Context.

Types

type NoCacheConfig added in v1.3.0

type NoCacheConfig struct {
	// Skipper defines a function to skip middleware.
	Skipper middleware.Skipper
}

NoCacheConfig used to configure the no cache middleware.

type OriginVerifierConfig added in v1.5.0

type OriginVerifierConfig struct {
	// Token used to validate requests coming include the required header
	Token string

	// Skipper defines a function to skip middleware.
	Skipper middleware.Skipper
}

OriginVerifierConfig used to configure the origin authentication middleware.

type ZeroLogConfig

type ZeroLogConfig struct {
	Caller bool
	Level  zerolog.Level
	Output io.Writer
	Logger zerolog.Logger
	Fields map[string]interface{}
}

ZeroLogConfig used to configure the zerolog echo middleware.

type ZeroLogRequestLogConfig added in v1.1.0

type ZeroLogRequestLogConfig struct {
	// Skipper defines a function to skip middleware.
	Skipper middleware.Skipper
}

ZeroLogRequestLogConfig defines the config for the request logger middleware.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL