mirror of
https://github.com/kataras/iris.git
synced 2025-02-02 07:20:35 +01:00
add IsDebug() shortcut method
This commit is contained in:
parent
ae67987f55
commit
b17217444e
|
@ -609,7 +609,8 @@ New Package-level Variables:
|
|||
|
||||
New Context Methods:
|
||||
|
||||
- `Context.IsRecovered()` reports whether the current request was recovered from the [recover middleware](https://github.com/kataras/iris/tree/master/middleware/recover). Also the `iris.IsErrPrivate` function and `iris.ErrPrivate` interface have been introduced.
|
||||
- `Context.IsDebug() bool` reports whether the application is running under debug/development mode. It is a shortcut of Application.Logger().Level >= golog.DebugLevel.
|
||||
- `Context.IsRecovered() bool` reports whether the current request was recovered from the [recover middleware](https://github.com/kataras/iris/tree/master/middleware/recover). Also the `iris.IsErrPrivate` function and `iris.ErrPrivate` interface have been introduced.
|
||||
- `Context.RecordBody()` same as the Application's `DisableBodyConsumptionOnUnmarshal` configuration field but registers per chain of handlers. It makes the request body readable more than once.
|
||||
- `Context.IsRecordingBody() bool` reports whether the request body can be readen multiple times.
|
||||
- `Context.ReadHeaders(ptr interface{}) error` binds request headers to "ptr". [Example](https://github.com/kataras/iris/blob/master/_examples/request-body/read-headers/main.go).
|
||||
|
|
2
cache/client/handler.go
vendored
2
cache/client/handler.go
vendored
|
@ -93,7 +93,7 @@ func getOrSetKey(ctx *context.Context) string {
|
|||
}
|
||||
|
||||
// Note: by-default the rules(ruleset pkg)
|
||||
// explictly ignores the cache handler
|
||||
// explicitly ignores the cache handler
|
||||
// execution on authenticated requests
|
||||
// and immediately runs the next handler:
|
||||
// if !h.rule.Claim(ctx) ...see `Handler` method.
|
||||
|
|
|
@ -19,6 +19,11 @@ type Application interface {
|
|||
|
||||
// Logger returns the golog logger instance(pointer) that is being used inside the "app".
|
||||
Logger() *golog.Logger
|
||||
// IsDebug reports whether the application is running
|
||||
// under debug/development mode.
|
||||
// It's just a shortcut of Logger().Level >= golog.DebugLevel.
|
||||
// The same method existss as Context.IsDebug() too.
|
||||
IsDebug() bool
|
||||
|
||||
// I18nReadOnly returns the i18n's read-only features.
|
||||
I18nReadOnly() I18nReadOnly
|
||||
|
|
|
@ -5054,6 +5054,12 @@ func (ctx *Context) Application() Application {
|
|||
return ctx.app
|
||||
}
|
||||
|
||||
// IsDebug reports whether the application runs with debug log level.
|
||||
// It is a shortcut of Application.IsDebug().
|
||||
func (ctx *Context) IsDebug() bool {
|
||||
return ctx.app.IsDebug()
|
||||
}
|
||||
|
||||
const errorContextKey = "iris.context.error"
|
||||
|
||||
// SetErr is just a helper that sets an error value
|
||||
|
|
8
iris.go
8
iris.go
|
@ -276,6 +276,14 @@ func (app *Application) Logger() *golog.Logger {
|
|||
return app.logger
|
||||
}
|
||||
|
||||
// IsDebug reports whether the application is running
|
||||
// under debug/development mode.
|
||||
// It's just a shortcut of Logger().Level >= golog.DebugLevel.
|
||||
// The same method existss as Context.IsDebug() too.
|
||||
func (app *Application) IsDebug() bool {
|
||||
return app.logger.Level >= golog.DebugLevel
|
||||
}
|
||||
|
||||
// I18nReadOnly returns the i18n's read-only features.
|
||||
// See `I18n` method for more.
|
||||
func (app *Application) I18nReadOnly() context.I18nReadOnly {
|
||||
|
|
Loading…
Reference in New Issue
Block a user