Skip to content

v1.7.0 — status helpers

Latest

Choose a tag to compare

@acoshift acoshift released this 25 Nov 08:37
7c62ed3

Named status helpers, and error responses that callers can propagate.

Status helpers

BadRequest, Unauthorized, Forbidden, Conflict, UnprocessableEntity, TooManyRequests, InternalServerError, and ServiceUnavailable write the status and a message, then return ErrResponseWritten. An empty message uses the status text.

return ctx.Forbidden("nope")

NotFound is unchanged (404 page not found). Other codes stay on ctx.Status(code).Error(message).

Behavior change

Context.Error and Context.NotFound now return ErrResponseWritten after writing the body. Handler treats that error as already handled, including when wrapped, so return ctx.Error(...) still completes the request. A helper that returns it is non-nil, so if err != nil { return err } stops before a second write.

Callers that treated a nil return from Error or NotFound as success and then wrote their own body must propagate the error instead.

Tooling

  • Requires Go 1.26. Direct modules updated: parapet v0.19.2, testify v1.12.1, minify v2.25.0.
  • Repo guidance lives in AGENTS.md.

Full changelog: v1.6.0...v1.7.0 (#125, #126)