Documentation
¶
Overview ¶
Package problemtype defines canonical API problem type URIs.
Index ¶
- func BrowserResponse(w http.ResponseWriter, r *http.Request) http.ResponseWriter
- func HelpURL(code, caseID string) string
- func Is(problemURI, code string) bool
- func NewRequestID() string
- func URL(code string) string
- func Write(response http.ResponseWriter, status int, code, title, detail, caseID string) string
- func WriteWithDetails(response http.ResponseWriter, status int, code, title, detail, caseID string, ...) string
- func WriteWithRequestID(response http.ResponseWriter, requestID string, status int, ...)
- type Problem
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BrowserResponse ¶
func BrowserResponse(w http.ResponseWriter, r *http.Request) http.ResponseWriter
BrowserResponse opts a browser endpoint into html problems without changing api responses. the existing problem writer still owns codes and correlation.
func NewRequestID ¶
func NewRequestID() string
func Write ¶
func Write(response http.ResponseWriter, status int, code, title, detail, caseID string) string
Write sends an authored problem once and returns the ID for operational logs.
func WriteWithDetails ¶
func WriteWithDetails(response http.ResponseWriter, status int, code, title, detail, caseID string, details map[string]any) string
WriteWithDetails sends the same envelope with diagnostic fields approved by the serving API. callers own field selection and validation, not wire framing.
func WriteWithRequestID ¶
func WriteWithRequestID(response http.ResponseWriter, requestID string, status int, code, title, detail, caseID string)
WriteWithRequestID reuses a locally generated request ID when a shared operation has already recorded it. never pass an ID from an incoming request.
Types ¶
type Problem ¶
type Problem struct {
Type string `json:"type"`
Title string `json:"title"`
Status int `json:"status"`
Code string `json:"code"`
Detail string `json:"detail"`
RequestID string `json:"request_id"`
Details map[string]any `json:"details"`
}
Problem is the shared HTTP error envelope. an API owns its allowed codes, while this writer owns the fields and request correlation across services.