Documentation
¶
Index ¶
- Constants
- func OrgIDFromContext(ctx context.Context) uuid.UUID
- func WriteJSONError(w http.ResponseWriter, r *http.Request, message string, statusCode int)
- func WriteJSONErrorForVersion(w http.ResponseWriter, version versioning.Version, message string, ...)
- func WriteJSONResponse(w http.ResponseWriter, body any, errorBody any, code int)
Constants ¶
const ( Forbidden = "Forbidden" )
Variables ¶
This section is empty.
Functions ¶
func OrgIDFromContext ¶ added in v1.0.0
OrgIDFromContext extracts the organization ID from the context. Falls back to the default organization ID if not present.
func WriteJSONError ¶ added in v1.2.0
WriteJSONError writes a JSON-formatted error response using the negotiated API version from the request context. If r is nil or no version is in context, defaults to v1beta1. This should be used instead of http.Error() to ensure all error responses are JSON.
func WriteJSONErrorForVersion ¶ added in v1.2.0
func WriteJSONErrorForVersion(w http.ResponseWriter, version versioning.Version, message string, statusCode int)
WriteJSONErrorForVersion writes a version-correct JSON error response. Use this when the API version is known but no *http.Request is available (e.g. in OAPI error handler closures).
func WriteJSONResponse ¶ added in v1.1.0
func WriteJSONResponse(w http.ResponseWriter, body any, errorBody any, code int)
WriteJSONResponse is a version-independent response writer. For 2xx status codes, body is encoded as the response. For non-2xx, errorBody is encoded instead. Responses with no body (204, 304, 1xx) only write the status code.
Types ¶
This section is empty.