Skip to content

Missing problem constructors for common statuses (Unauthorized, Forbidden, Conflict, Unprocessable, Internal) #16

Description

@rluders

problem_helpers.go ships ProblemBadRequest/NewBadRequestProblem and ProblemNotFound/NewNotFoundProblem, but nothing for the other statuses that come up just as often in a typical API:

  • 401 Unauthorized
  • 403 Forbidden
  • 409 Conflict
  • 422 Unprocessable Entity
  • 500 Internal Server Error

Without these, every call site falls back to the fully manual httpsuite.NewProblemDetails(status, type, title, detail) — which is exactly the 4-argument ceremony the NewBadRequestProblem/NewNotFoundProblem helpers exist to avoid for those two statuses.

Measured impact in one consumer (GolgiMed, ~150k LOC): 845 manual NewProblemDetails(...) calls, of which ~730 are exactly the canonical (status, "unauthorized", "Unauthorized", detail) / (status, "forbidden", "Forbidden", detail) / etc. shape that a NewUnauthorizedProblem(detail) / NewForbiddenProblem(detail) would collapse to one line.

Requested: ProblemUnauthorized/NewUnauthorizedProblem, ProblemForbidden/NewForbiddenProblem, ProblemConflict/NewConflictProblem, ProblemUnprocessable/NewUnprocessableProblem, ProblemInternal/NewInternalProblem, matching the existing ProblemBadRequest/ProblemNotFound pattern.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions