1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-17 18:07:01 +00:00

minor improvement

This commit is contained in:
Gerasimos (Makis) Maropoulos
2023-11-15 11:57:52 +02:00
parent 5f749453c7
commit b1f2c24b64
2 changed files with 8 additions and 4 deletions

View File

@@ -2842,8 +2842,8 @@ func (ctx *Context) ReadYAML(outPtr interface{}) error {
var ( var (
// IsErrEmptyJSON reports whether the given "err" is caused by a // IsErrEmptyJSON reports whether the given "err" is caused by a
// Context.ReadJSON call when the request body // Client.ReadJSON call when the request body was empty or
// didn't start with { or it was totally empty. // didn't start with { or [.
IsErrEmptyJSON = func(err error) bool { IsErrEmptyJSON = func(err error) bool {
if err == nil { if err == nil {
return false return false
@@ -2858,8 +2858,9 @@ var (
return v.Offset == 0 && v.Error() == "unexpected end of JSON input" return v.Offset == 0 && v.Error() == "unexpected end of JSON input"
} }
// when optimization is enabled, the jsoniter will report the following error: errMsg := err.Error()
return strings.Contains(err.Error(), "readObjectStart: expect {") // 3rd party pacakges:
return strings.Contains(errMsg, "readObjectStart: expect {") || strings.Contains(errMsg, "readArrayStart: expect [")
} }
// IsErrPath can be used at `context#ReadForm` and `context#ReadQuery`. // IsErrPath can be used at `context#ReadForm` and `context#ReadQuery`.

View File

@@ -557,6 +557,9 @@ func (s *step7) Run(runner Runner, configurators ...Configurator) error {
// they will be called on interrupt signals too, // they will be called on interrupt signals too,
// because Iris has a builtin mechanism to call server's shutdown on interrupt. // because Iris has a builtin mechanism to call server's shutdown on interrupt.
for _, cb := range s.step6.closers { for _, cb := range s.step6.closers {
if cb == nil {
continue
}
cb() cb()
} }
}() }()