minor improvement

This commit is contained in:
Gerasimos (Makis) Maropoulos 2023-11-15 11:57:52 +02:00
parent 5f749453c7
commit b1f2c24b64
No known key found for this signature in database
GPG Key ID: B9839E9CD30B7B6B
2 changed files with 8 additions and 4 deletions

View File

@ -2842,8 +2842,8 @@ func (ctx *Context) ReadYAML(outPtr interface{}) error {
var (
// IsErrEmptyJSON reports whether the given "err" is caused by a
// Context.ReadJSON call when the request body
// didn't start with { or it was totally empty.
// Client.ReadJSON call when the request body was empty or
// didn't start with { or [.
IsErrEmptyJSON = func(err error) bool {
if err == nil {
return false
@ -2858,8 +2858,9 @@ var (
return v.Offset == 0 && v.Error() == "unexpected end of JSON input"
}
// when optimization is enabled, the jsoniter will report the following error:
return strings.Contains(err.Error(), "readObjectStart: expect {")
errMsg := err.Error()
// 3rd party pacakges:
return strings.Contains(errMsg, "readObjectStart: expect {") || strings.Contains(errMsg, "readArrayStart: expect [")
}
// 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,
// because Iris has a builtin mechanism to call server's shutdown on interrupt.
for _, cb := range s.step6.closers {
if cb == nil {
continue
}
cb()
}
}()