Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoggingMiddleware ¶
LoggingMiddleware wraps h and returns a new handler that logs the request that came in, adding information like response code and duration.
func WriteErr ¶
func WriteErr(w http.ResponseWriter, err error)
WriteErr writes out an error as JSON to w.
The code sent back is dependent on the [api.Error]'s code that is passed in.
This ensures that all errors being written out are of the [api.Error] type, but if a given err is not, it's wrapped in one and returns a 500.
func WriteJSON ¶
func WriteJSON(w http.ResponseWriter, a any)
WriteJSON sends JSON back with the right headers to the http.ResponseWriter.
In case there's an error, it writes the error back and returns a 500.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.