Documentation ¶
Index ¶
- Variables
- func AllowAccept(contentTypes ...string) func(http.Handler) http.Handler
- func AllowContentType(contentTypes ...string) func(http.Handler) http.Handler
- func AllowHTTPHeader(badStatus int, name string, values ...string) func(http.Handler) http.Handler
- func AllowMethod(methods ...string) func(http.Handler) http.Handler
- func AllowUserAgent(userAgents ...string) func(http.Handler) http.Handler
- func CacheControl(opts ...string) func(http.Handler) http.Handler
- func Clickjacking(opt string) func(http.Handler) http.Handler
- func ContentSniffing() func(http.Handler) http.Handler
- func Context(f ContextFunc) func(http.Handler) http.Handler
- func DisallowAccept(contentTypes ...string) func(http.Handler) http.Handler
- func DisallowContentType(contentTypes ...string) func(http.Handler) http.Handler
- func DisallowHTTPHeader(badStatus int, name string, values ...string) func(http.Handler) http.Handler
- func DisallowMethod(methods ...string) func(http.Handler) http.Handler
- func DisallowUserAgent(userAgents ...string) func(http.Handler) http.Handler
- func HSTS(maxAge int, opt string) func(http.Handler) http.Handler
- func NoCache() func(http.Handler) http.Handler
- func RealIP() func(http.Handler) http.Handler
- func Recover(out io.Writer) func(http.Handler) http.Handler
- func RequestHeader(fs ...HeaderFunc) func(http.Handler) http.Handler
- func ResponseHeader(fs ...HeaderFunc) func(http.Handler) http.Handler
- func Stampede(d time.Duration) func(http.Handler) http.Handler
- func Timeout(d time.Duration) func(http.Handler) http.Handler
- func Use(middlewares ...func(http.Handler) http.Handler) func(http.Handler) http.Handler
- type ContextFunc
- type HeaderFunc
Constants ¶
This section is empty.
Variables ¶
var HoneypotUserAgents = []string{
"0xSCANNER",
"20010801",
"AhrefsBot",
"Alprazolam",
"BLEXBot",
"BOT for JCE",
"Baiduspider",
"Gecko/20100115",
"Gemini",
"Hakai",
"Hello",
"Indy Library",
"Indy-Library",
"JDatabaseDriverMysqli",
"Jorgee",
"LMAO",
"MJ12bot",
"Mappy",
"Morfeus",
"NYU",
"Nessus",
"Nikto",
"OpenVAS",
"Ronin",
"SemrushBot",
"Shinka",
"WPScan",
"ZmEu",
"aiohttp",
"masscan",
"muhstik",
"sqlmap",
"sysscan",
"union select",
"yandex",
"zgrab",
}
HoneypotUserAgents ...
Functions ¶
func AllowAccept ¶ added in v0.4.0
AllowAccept is middleware that allows a request only if any of the specified strings is included in the Accept header. Returns 406 Not Acceptable status if the request has a type that is not allowed.
func AllowContentType ¶ added in v0.2.0
AllowContentType is middleware that allows a request only if any of the specified strings is included in the Content-Type header. Returns 415 Unsupported Media Type status if the request has a type that is not allowed.
func AllowHTTPHeader ¶
AllowHTTPHeader is middleware that allows a request only when one of the specified strings is included in the specified request header.
func AllowMethod ¶ added in v0.3.0
AllowMethod is a middleware that returns a 405 Method Not Allowed status if the request method is not one of the given methods.
func AllowUserAgent ¶
AllowUserAgent is middleware that allows a request only if any of the specified strings is included in the User-Agent header. Returns 403 Forbidden status if the request has a user-agent that is not allowed.
func CacheControl ¶ added in v0.3.0
CacheControl adds the Cache-Control header.
func Clickjacking ¶ added in v0.2.0
Clickjacking mitigates clickjacking attacks by limiting the display of iframe.
func ContentSniffing ¶ added in v0.2.0
ContentSniffing adds a header for Content-Type sniffing vulnerability countermeasures.
func Context ¶
func Context(f ContextFunc) func(http.Handler) http.Handler
Context is middleware that edits the context of the request.
func DisallowAccept ¶ added in v0.4.0
DisallowAccept is middleware that disallow a request only if any of the specified strings is included in the Accept header. Returns 406 Not Acceptable status if the request has a type that is not allowed.
func DisallowContentType ¶ added in v0.2.0
DisallowContentType is middleware that disallow a request only if any of the specified strings is included in the Content-Type header. Returns 415 Unsupported Media Type status if the request has a type that is not allowed.
func DisallowHTTPHeader ¶
func DisallowHTTPHeader(badStatus int, name string, values ...string) func(http.Handler) http.Handler
DisallowHTTPHeader is middleware that disallows a request only when one of the specified strings is included in the specified request header.
func DisallowMethod ¶ added in v0.3.0
DisallowMethod is a middleware that returns a 405 Method Not Allowed status if the request method is one of the given methods.
func DisallowUserAgent ¶
DisallowUserAgent is middleware that disallow a request only if any of the specified strings is included in the User-Agent header. Returns 403 Forbidden status if the request has a user-agent that is not allowed.
func HSTS ¶ added in v0.2.0
HSTS adds the Strict-Transport-Security header. Proper use of this header will mitigate stripping attacks.
func RealIP ¶ added in v0.3.0
RealIP is middleware that overwrites RemoteAddr of http.Request with X-Forwarded-For or X-Real-IP header. Validation of the X-Forwarded-For header is done from right to left.
func Recover ¶ added in v0.3.0
Recover is a middleware that recovers from panic and records a stack trace and returns a 500 Internal Server Error status.
func RequestHeader ¶ added in v0.2.0
func RequestHeader(fs ...HeaderFunc) func(http.Handler) http.Handler
RequestHeader is middleware that edits the header of the request.
func ResponseHeader ¶ added in v0.2.0
func ResponseHeader(fs ...HeaderFunc) func(http.Handler) http.Handler
ResponseHeader is middleware that edits the header of the response.
func Stampede ¶ added in v0.5.0
Stampede provides a simple cache middleware that is valid for a specified amount of time. It uses singleflight for caching to prevent thundering-herd and cache-stampede. If this middleware is requested at the same time, it executes the handler only once and shares the execution result with all requests.
Types ¶
type HeaderFunc ¶ added in v0.2.0
HeaderFunc ...
func CacheControlHeaderFunc ¶ added in v0.3.0
func CacheControlHeaderFunc(opts ...string) HeaderFunc
CacheControlHeaderFunc returns a HeaderFunc that adds a Cache-Control header.
func ClickjackingHeaderFunc ¶ added in v0.2.0
func ClickjackingHeaderFunc(opt string) HeaderFunc
ClickjackingHeaderFunc returns a HeaderFunc to mitigate a clickjacking vulnerability.
func ContentSniffingHeaderFunc ¶ added in v0.2.0
func ContentSniffingHeaderFunc() HeaderFunc
ContentSniffingHeaderFunc returns a HeaderFunc for Content-Type sniffing vulnerability countermeasure.
func HSTSHeaderFunc ¶ added in v0.2.0
func HSTSHeaderFunc(maxAge int, opt string) HeaderFunc
HSTSHeaderFunc returns a HeaderFunc that adds a Strict-Transport-Security header.
func NoCacheHeaderFunc ¶ added in v0.3.0
func NoCacheHeaderFunc() HeaderFunc
NoCacheHeaderFunc returns the HeaderFunc to add the Cache-Control header that disables the cache.