middleware

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2022 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CORS

type CORS struct {
	// Origin is a function that returns a value of
	// an Access-Control-Allow-Origin header. It cannot be nil.
	Origin func(r *http.Request) string
	// Headers is a function that returns a value of
	// an Access-Control-Allow-Headers header. It cannot be nil.
	Headers func(r *http.Request) string
	// Methods is a function that returns a value of
	// an Access-Control-Allow-Methods. It cannot be nil.
	Methods func(r *http.Request) string
}

CORS adds a basic support for CORS preflight requests.

func (*CORS) Handle

func (c *CORS) Handle(next http.Handler) http.Handler

Handle implements the httpserver.Middleware interface.

type Logger

type Logger struct {
	// Log is an instance of a log.Logger. It cannot be nil, otherwise code will panic.
	Log log.Logger
}

Logger prints logs for each request. If the log level is set to debug, it will print the contents of requests and responses.

func (*Logger) Handle

func (l *Logger) Handle(next http.Handler) http.Handler

Handle implements the httpserver.Middleware interface.

type Recover

type Recover struct {
	// Recover is an optional function that will be invoked during panicking.
	// It can be nil.
	Recover func(err interface{})
}

Recover recovers from panics that occurred during invoking handler's ServeHTTP method.

func (*Recover) Handle

func (c *Recover) Handle(next http.Handler) http.Handler

Handle implements the httpserver.Middleware interface.

Jump to

Keyboard shortcuts

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