feat: release v0.27 unified HTTP limits and safe request shutdown
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"net/http"
|
||||
|
||||
apierrors "git.yuntuo.hk/k2safe/go-omni/errors"
|
||||
"git.yuntuo.hk/k2safe/go-omni/internal/httplimits"
|
||||
"git.yuntuo.hk/k2safe/go-omni/logx"
|
||||
"git.yuntuo.hk/k2safe/go-omni/response"
|
||||
"git.yuntuo.hk/k2safe/go-omni/validate"
|
||||
@@ -284,7 +285,12 @@ func (c *Context) WriteError(err error) {
|
||||
if errors.As(err, &bodyErr) {
|
||||
err = bodyTooLarge()
|
||||
}
|
||||
var original *apierrors.APIError
|
||||
tooLarge := errors.As(err, &original) && original.Status == http.StatusRequestEntityTooLarge
|
||||
apiErr := c.ResolveError(err)
|
||||
if tooLarge || apiErr.Status == http.StatusRequestEntityTooLarge {
|
||||
httplimits.RejectBody(c.Raw())
|
||||
}
|
||||
c.failure = apiErr
|
||||
if writeErr := c.writeResult(response.Result{
|
||||
BusinessCode: apiErr.BusinessCode,
|
||||
|
||||
Reference in New Issue
Block a user