mirror of
https://github.com/kataras/iris.git
synced 2025-12-17 09:57:01 +00:00
add 'Context.Register/RemoveDependency' for registering dependencies for next handler in the chain from a common iris handler in serve-time
And also, add a Configuration.FireEmptyFormError if end-dev wants to receive an iris.ErrEmptyForm error on missing form data on 'Context.ReadForm/ReadBody' Former-commit-id: a2713bec77375b2908f1f066a46be4f19e6b7a61
This commit is contained in:
@@ -262,6 +262,13 @@ var WithoutBodyConsumptionOnUnmarshal = func(app *Application) {
|
||||
app.config.DisableBodyConsumptionOnUnmarshal = true
|
||||
}
|
||||
|
||||
// WithEmptyFormError enables the setting `FireEmptyFormError`.
|
||||
//
|
||||
// See `Configuration`.
|
||||
var WithEmptyFormError = func(app *Application) {
|
||||
app.config.FireEmptyFormError = true
|
||||
}
|
||||
|
||||
// WithoutAutoFireStatusCode disables the AutoFireStatusCode setting.
|
||||
//
|
||||
// See `Configuration`.
|
||||
@@ -837,6 +844,9 @@ type Configuration struct {
|
||||
// The body will not be changed and existing data before the
|
||||
// context.UnmarshalBody/ReadJSON/ReadXML will be not consumed.
|
||||
DisableBodyConsumptionOnUnmarshal bool `json:"disableBodyConsumptionOnUnmarshal,omitempty" yaml:"DisableBodyConsumptionOnUnmarshal" toml:"DisableBodyConsumptionOnUnmarshal"`
|
||||
// FireEmptyFormError returns if set to tue true then the `context.ReadBody/ReadForm`
|
||||
// will return an `iris.ErrEmptyForm` on empty request form data.
|
||||
FireEmptyFormError bool `json:"fireEmptyFormError,omitempty" yaml:"FireEmptyFormError" yaml:"FireEmptyFormError"`
|
||||
|
||||
// DisableAutoFireStatusCode if true then it turns off the http error status code handler automatic execution
|
||||
// from (`context.StatusCodeNotSuccessful`, defaults to < 200 || >= 400).
|
||||
@@ -1021,6 +1031,13 @@ func (c Configuration) GetDisableBodyConsumptionOnUnmarshal() bool {
|
||||
return c.DisableBodyConsumptionOnUnmarshal
|
||||
}
|
||||
|
||||
// GetFireEmptyFormError returns the Configuration.FireEmptyFormError value.
|
||||
// If true then the `context.ReadBody/ReadForm` will return an `iris.ErrEmptyForm`
|
||||
// on empty request form data.
|
||||
func (c Configuration) GetFireEmptyFormError() bool {
|
||||
return c.DisableBodyConsumptionOnUnmarshal
|
||||
}
|
||||
|
||||
// GetDisableAutoFireStatusCode returns the Configuration#DisableAutoFireStatusCode.
|
||||
// Returns true when the http error status code handler automatic execution turned off.
|
||||
func (c Configuration) GetDisableAutoFireStatusCode() bool {
|
||||
@@ -1190,6 +1207,10 @@ func WithConfiguration(c Configuration) Configurator {
|
||||
main.DisableBodyConsumptionOnUnmarshal = v
|
||||
}
|
||||
|
||||
if v := c.FireEmptyFormError; v {
|
||||
main.FireEmptyFormError = v
|
||||
}
|
||||
|
||||
if v := c.DisableAutoFireStatusCode; v {
|
||||
main.DisableAutoFireStatusCode = v
|
||||
}
|
||||
@@ -1261,6 +1282,7 @@ func DefaultConfiguration() Configuration {
|
||||
ForceLowercaseRouting: false,
|
||||
FireMethodNotAllowed: false,
|
||||
DisableBodyConsumptionOnUnmarshal: false,
|
||||
FireEmptyFormError: false,
|
||||
DisableAutoFireStatusCode: false,
|
||||
TimeFormat: "Mon, 02 Jan 2006 15:04:05 GMT",
|
||||
Charset: "utf-8",
|
||||
|
||||
Reference in New Issue
Block a user