Browse Source

add IsDebug() shortcut method

tags/v12.2.0-alpha
Gerasimos (Makis) Maropoulos 1 year ago
parent
commit
b17217444e
No known key found for this signature in database GPG Key ID: 5DBE766BD26A54E7
5 changed files with 22 additions and 2 deletions
  1. +2
    -1
      HISTORY.md
  2. +1
    -1
      cache/client/handler.go
  3. +5
    -0
      context/application.go
  4. +6
    -0
      context/context.go
  5. +8
    -0
      iris.go

+ 2
- 1
HISTORY.md View File

@@ -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).


+ 1
- 1
cache/client/handler.go View File

@@ -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.


+ 5
- 0
context/application.go View File

@@ -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


+ 6
- 0
context/context.go View File

@@ -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
- 0
iris.go View File

@@ -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…
Cancel
Save