Documentation
¶
Overview ¶
Package handlers provides common HTTP handler utilities.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HandleRepositoryError ¶
HandleRepositoryError checks if the error is a record not found error and responds with appropriate HTTP status code (404 or 500). For internal errors, it logs the error with structured logging.
func LogAndRespondError ¶
LogAndRespondError logs the error with context and responds with the given status code. Use this for non-repository errors (auth failures, validation errors, external service errors).
func RespondError ¶
RespondError responds with an error without logging (for expected errors like validation failures). Use this when the error is not exceptional and doesn't need logging (e.g., invalid input). Sole producer of the error envelope every service returns.
func SetLocationHeader ¶
SetLocationHeader sets the Location header for created resources. Follows REST convention of providing URI to newly created resource.
Types ¶
This section is empty.