middlewares

package
v0.0.0-...-8131af5 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthRequired

func AuthRequired(
	_ *scraper.Service,
) func(targetMux http.Handler) http.Handler

AuthRequired represents a authentication guard

func Logger

func Logger(params LogParams) func(targetMux http.Handler) http.Handler

Logger log all requests

func RealIP

func RealIP() func(h http.Handler) http.Handler

RealIP is a middleware that sets a http.Request's RemoteAddr to the results of parsing either the True-Client-IP, X-Real-IP or the X-Forwarded-For headers (in that order).

This middleware should be inserted fairly early in the middleware stack to ensure that subsequent layers (e.g., request loggers) which examine the RemoteAddr will see the intended value.

You should only use this middleware if you can trust the headers passed to you (in particular, the two headers this middleware uses), for example because you have placed a reverse proxy like HAProxy or nginx in front of chi. If your reverse proxies are configured to pass along arbitrary header values from the client, or if you use this middleware without a reverse proxy, malicious clients will be able to make you very sad (or, depending on how you're using RemoteAddr, vulnerable to an attack of some sort).

func SetupCors

func SetupCors() func(targetMux http.Handler) http.Handler

SetupCors middleware

func VisitorCookie

func VisitorCookie() func(targetMux http.Handler) http.Handler

VisitorCookie middleware

Types

type LogParams

type LogParams struct {
	LogCfg applog.LogConfig
	Log    zerolog.Logger
}

LogParams represents a logger params

Jump to

Keyboard shortcuts

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