server

package
v0.0.0-...-06bfaea Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 5, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoggingMiddleware

func LoggingMiddleware(h http.Handler) http.Handler

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL