Documentation ¶
Index ¶
- Variables
- func AddLogger(next router.Handler) router.Handler
- func AddUserMiddleware(f func(*request.Request) request.User) router.Middleware
- func AllowContentType(contentTypes ...string) func(next router.Handler) router.Handler
- func AllowedHosts(allowed_hosts ...string) func(next router.Handler) router.Handler
- func Cache(maxAge int) func(next router.Handler) router.Handler
- func GZIP(next router.Handler) router.Handler
- func LoginRequiredMiddleware(notAuth func(r *request.Request)) func(next router.Handler) router.Handler
- func LoginRequiredRedirectMiddleware(nextURL string) func(next router.Handler) router.Handler
- func LogoutRequiredMiddleware(isAuth func(r *request.Request)) func(next router.Handler) router.Handler
- func LogoutRequiredRedirectMiddleware(nextURL string) func(next router.Handler) router.Handler
- func NoCache(next router.Handler) router.Handler
- func Printer(next router.Handler) router.Handler
- func PrinterFunc(next router.Handler, out io.Writer) router.Handler
- func RateLimiterMiddleware(conf *RateLimitOptions) func(next router.Handler) router.Handler
- func Recoverer(next router.Handler) router.Handler
- type RateLimitOptions
- type RateLimitType
Constants ¶
This section is empty.
Variables ¶
var DEFAULT_LOGGER request.Logger
Functions ¶
func AddUserMiddleware ¶ added in v2.1.8
Helper function to more easily add a user to the request.
func AllowContentType ¶
func AllowContentType(contentTypes ...string) func(next router.Handler) router.Handler
func AllowedHosts ¶
func AllowedHosts(allowed_hosts ...string) func(next router.Handler) router.Handler
Check if the request.Host is in the allowed hosts list
func LoginRequiredMiddleware ¶ added in v2.0.1
func LoginRequiredMiddleware(notAuth func(r *request.Request)) func(next router.Handler) router.Handler
Middleware that only allows users who are authenticated to continue. By default, will call the notAuth function. Configure the AddUserMiddleware to change the default behavior.
func LoginRequiredRedirectMiddleware ¶ added in v2.0.1
func LoginRequiredRedirectMiddleware(nextURL string) func(next router.Handler) router.Handler
Middleware that only allows users who are authenticated to continue. By default, will always redirect. Set the following function to change the default behavior: Configure the AddUserMiddleware to change the default behavior.
func LogoutRequiredMiddleware ¶ added in v2.0.1
func LogoutRequiredMiddleware(isAuth func(r *request.Request)) func(next router.Handler) router.Handler
Middleware that only allows users who are not authenticated to continue By default, will never call the isAuth function. Set the following function to change the default behavior: Configure the AddUserMiddleware to change the default behavior.
func LogoutRequiredRedirectMiddleware ¶ added in v2.0.5
func LogoutRequiredRedirectMiddleware(nextURL string) func(next router.Handler) router.Handler
Middleware that only allows users who are not authenticated to continue By default, will never call the isAuth function. Set the following function to change the default behavior: Configure the AddUserMiddleware to change the default behavior.
func PrinterFunc ¶ added in v2.0.3
func RateLimiterMiddleware ¶ added in v2.5.3
func RateLimiterMiddleware(conf *RateLimitOptions) func(next router.Handler) router.Handler
Rate Limiter Middleware
Types ¶
type RateLimitOptions ¶ added in v2.5.3
type RateLimitOptions struct { CookieName string Type RateLimitType RequestsPerSecond int BurstMultiplier int CleanExpiry time.Duration CleanInt time.Duration LimitHandler func(r *request.Request) }
RateLimitOptions is a struct that holds the options for the rate limiter.
type RateLimitType ¶ added in v2.5.3
type RateLimitType int
Rate limit types.
const ( RateLimitIP RateLimitType = iota RateLimitIP_Proxy RateLimitCookie )
Rate limit types, used to determine what to rate limit with.