Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RealIP ¶
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 three 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 Recoverer ¶
Recoverer is a middleware that recovers from panics, logs the panic (and a backtrace), and returns a HTTP 500 (Internal Server Error) status if possible. Recoverer prints a request ID if one is provided.
func RequestID ¶
RequestID is a middleware that injects a request ID into the context of each request. A request ID is a string of the form "host.example.com/random-0001", where "random" is a base62 random string that uniquely identifies this go process, and where the last number is an atomically incremented request counter.
Types ¶
type FrameworkTrace ¶
type FrameworkTrace struct {
AdeleVersion string
AppName string
RootPath string
FrameCount int
GoVersion string
FileName string
FilePath string
PackagePath string
MainPath string
PanicMessage string
PanicType string
PanicLine string
Stack []FrameworkTraceEntry
StackFormatted []string
StackRaw []byte
SourceRaw string
SourceFormatted []string
SourceHighlight string
}
type FrameworkTraceEntry ¶
type Middleware ¶
type Middleware struct {
Cookie Cookie
FrameworkVersion string
AppName string
RootPath string
Log *logrus.Logger
MaintenanceMode bool
Session *scs.SessionManager
Rate int
Duration time.Duration
Limit func(requestLimit int, windowLength time.Duration, options ...httprate.Option) func(next http.Handler) http.Handler
}
func (*Middleware) CheckForMaintenanceMode ¶
func (a *Middleware) CheckForMaintenanceMode(next http.Handler) http.Handler
func (*Middleware) RateLimiter ¶
func (a *Middleware) RateLimiter() func(next http.Handler) http.Handler
func (*Middleware) RecovererWithDebug ¶
func (m *Middleware) RecovererWithDebug(next http.Handler) http.Handler
The recover with debug middleware is designed to manage the panic behavior of the framework by catching the panic sequence and restoring normal execution. When this takes place, the middleware will render a built-in go template that displays the panic message and related information. Please see the FrameworkTrace struct for details about what information is displayed in the user interface.
func (*Middleware) SessionLoad ¶
func (a *Middleware) SessionLoad(next http.Handler) http.Handler
Load and save session on each request