caddyhttp: use errors.AsType for request body limit errors (#8090)
With the Go 1.26 floor, golangci-lint's modernize analyzer (errorsastype) flags the three errors.As calls that look for RequestBodyLimitError, which turned the Lint workflow red on master after #8056. Replace them with the generic errors.AsType; behavior is unchanged. Assistance disclosure: this change was made by an AI agent (Claude Sonnet 5.5, model ID claude-sonnet-5-5) acting as Matthew Holt's agent and under his approval. Build, go vet and the caddyhttp and caddyhttp/templates tests pass locally; golangci-lint itself was not run locally. Co-authored-by: Claude Code <noreply@anthropic.com>
This commit is contained in:
parent
90efc8fe64
commit
0a137e2faf
2 changed files with 3 additions and 6 deletions
|
|
@ -268,8 +268,7 @@ func (c TemplateContext) funcPlaceholder(name string) (string, error) {
|
|||
// server renders the 413, and any other value, including unrelated
|
||||
// errors, is converted to a string as before
|
||||
if err, ok := value.(error); ok {
|
||||
var bodyLimit caddyhttp.RequestBodyLimitError
|
||||
if errors.As(err, &bodyLimit) {
|
||||
if bodyLimit, ok := errors.AsType[caddyhttp.RequestBodyLimitError](err); ok {
|
||||
return "", caddyhttp.HandlerError{Err: bodyLimit, StatusCode: bodyLimit.StatusCode()}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -203,8 +203,7 @@ func (m VarsMatcher) MatchWithError(r *http.Request) (bool, error) {
|
|||
// request_body max_size limit when {http.request.body} is
|
||||
// truncated) instead of matching on its error text; unrelated
|
||||
// errors are matched on their text as before
|
||||
var bodyLimit RequestBodyLimitError
|
||||
if errors.As(vv, &bodyLimit) {
|
||||
if bodyLimit, ok := errors.AsType[RequestBodyLimitError](vv); ok {
|
||||
// wrap in a status-carrying handler error so the server
|
||||
// renders the 413
|
||||
return false, HandlerError{Err: bodyLimit, StatusCode: bodyLimit.StatusCode()}
|
||||
|
|
@ -350,8 +349,7 @@ func (m MatchVarsRE) MatchWithError(r *http.Request) (bool, error) {
|
|||
// request_body max_size limit when {http.request.body} is
|
||||
// truncated) instead of matching on its error text; unrelated
|
||||
// errors are matched on their text as before
|
||||
var bodyLimit RequestBodyLimitError
|
||||
if errors.As(vv, &bodyLimit) {
|
||||
if bodyLimit, ok := errors.AsType[RequestBodyLimitError](vv); ok {
|
||||
// wrap in a status-carrying handler error so the server
|
||||
// renders the 413
|
||||
return false, HandlerError{Err: bodyLimit, StatusCode: bodyLimit.StatusCode()}
|
||||
|
|
|
|||
Loading…
Reference in a new issue