Documentation
¶
Overview ¶
Package web provides utilities for constructing HTTP responses.
Index ¶
Constants ¶
View Source
const (
ContentTypeApplicationJSON = "application/json"
)
Variables ¶
This section is empty.
Functions ¶
func ContentType ¶
func ContentType(w http.ResponseWriter, ct string)
ContentType sets the Content-Type header.
func Header ¶
func Header(w http.ResponseWriter, key, value string)
Header sets a header key to a single value.
func JSON ¶
func JSON(w http.ResponseWriter, body any)
JSON writes the JSON representation of the provided data to a response.
func NewInt ¶
NewInt converts a string to an int64 and is primarily used for parsing incoming form values.
func NewString ¶
NewString sanitizes its input and returns the result. This is primarily used for parsing incoming form values.
func StatusCode ¶
func StatusCode(w http.ResponseWriter, code int)
StatusCode sets the HTTP status code.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.