middleware

package
v0.0.0-...-b9a316c Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package middleware defines some generic middleware.

Index

Constants

This section is empty.

Variables

View Source
var SetRequestID = middleware.RequestID

SetRequestID sets the request ID in the context.

Functions

func ErrorPage

func ErrorPage(statusCode int, f http.HandlerFunc) func(http.Handler) http.Handler

ErrorPage runs the given function if the response contains the given status code.

func LogRequest

func LogRequest(next http.Handler) http.Handler

LogRequest logs information about the request.

It will panic if no logger is found in the context.

func Logger

func Logger(r *http.Request) logrus.FieldLogger

Logger returns the logger for the given request.

Panics if the logger is not found.

func Neuter

func Neuter(next http.Handler) http.Handler

Neuter responds with a 404 Not Found if the path ends with a '/'.

func SetContentType

func SetContentType(contentType string) func(http.Handler) http.Handler

SetContentType sets the content type of the response.

func SetLogger

func SetLogger(l logrus.FieldLogger) func(http.Handler) http.Handler

SetLogger sets the logger in the context.

This should be used in conjunction with SetRequestID.

Types

This section is empty.

Jump to

Keyboard shortcuts

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