middleware

package
v0.0.38 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	XFrameOptionsSameOrigin = "sameorigin"
	XFrameOptionsDeny       = "deny"
)

constants for the X-Frame-Options header

View Source
const RequestHeader = "X-Http-Request-Id"

RequestHeader is the header that marks the http request id set by the server.

Variables

This section is empty.

Functions

func Compress

func Compress(h http.Handler) http.Handler

Compress is middleware that implements gzip compression

func FrameOptions

func FrameOptions(policy string) func(http.Handler) http.Handler

FrameOptions is middleware that sets the X-Frame-Options header. Policy should be one of deny|sameorigin|allow-from https://example.com/

func GetReqID

func GetReqID(ctx context.Context) string

GetReqID returns any request id that had been set in the context.

func NoCache

func NoCache(h http.Handler) http.Handler

NoCache is a simple piece of middleware that sets a number of HTTP headers to prevent a router (or subrouter) from being cached by an upstream proxy and/or client.

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 RequestID

func RequestID(next http.Handler) http.Handler

RequestID sets the request id in the context to a uuid that can be traced throughout the servers req/resp lifecycle.

func SanitizeQuery

func SanitizeQuery(vals url.Values) url.Values

SanitizeQuery used to sanitize the query params of any secrets so they do not show up in logs.

Types

This section is empty.

Jump to

Keyboard shortcuts

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