Documentation
¶
Index ¶
- Constants
- func GetHeader(r *http.Request, key string) string
- func GetHeaderOr(r *http.Request, key string, defaultValue string) string
- func GetQueryBool(r *http.Request, key string) (bool, error)
- func GetQueryBoolOr(r *http.Request, key string, defaultValue bool) bool
- func GetQueryInt(r *http.Request, key string) (int, error)
- func GetQueryIntOr(r *http.Request, key string, defaultValue int) int
- func GetQueryParam(r *http.Request, key string) string
- func GetQueryParamOr(r *http.Request, key string, defaultValue string) string
- func HTML(w http.ResponseWriter, content string) error
- func IsDelete(r *http.Request) bool
- func IsGet(r *http.Request) bool
- func IsPatch(r *http.Request) bool
- func IsPost(r *http.Request) bool
- func IsPut(r *http.Request) bool
- func JSON(w http.ResponseWriter, value any) error
- func JSONBadRequest(w http.ResponseWriter, message string) error
- func JSONCreated(w http.ResponseWriter, value any) error
- func JSONError(w http.ResponseWriter, message string, status int) error
- func JSONForbidden(w http.ResponseWriter, message string) error
- func JSONInternalError(w http.ResponseWriter, message string) error
- func JSONNotFound(w http.ResponseWriter, message string) error
- func JSONStatus(w http.ResponseWriter, value any, status int) error
- func JSONUnauthorized(w http.ResponseWriter, message string) error
- func MethodNotAllowed(w http.ResponseWriter, allowed ...string)
- func NoContent(w http.ResponseWriter)
- func ReadJSON(r *http.Request, target any) error
- func ReadJSONAndClose(r *http.Request, target any) error
- func ReadJSONLimit(r *http.Request, maxBytes int64, target any) error
- func Redirect(w http.ResponseWriter, r *http.Request, url string)
- func RedirectPermanent(w http.ResponseWriter, r *http.Request, url string)
- func SafeHTML(w http.ResponseWriter, content string) error
- func SafeRedirect(w http.ResponseWriter, r *http.Request, redirectURL string, ...) error
- func SafeURL(tmpl string, pathParams map[string]string, queryParams map[string]string) (string, error)
- func SecureHeaders(handler http.Handler) http.Handler
- func Serve(addr string, handler http.Handler) error
- func SetSecureHeaders(w http.ResponseWriter)
- func Text(w http.ResponseWriter, content string) error
- func TextStatus(w http.ResponseWriter, content string, status int) error
- func WithCSRF(handler http.Handler) http.Handler
Constants ¶
View Source
const ContentForm = "application/x-www-form-urlencoded"
View Source
const ContentHTML = "text/html; charset=utf-8"
View Source
const ContentJSON = "application/json"
View Source
const ContentMultipart = "multipart/form-data"
View Source
const ContentText = "text/plain; charset=utf-8"
View Source
const HeaderAccept = "Accept"
View Source
const HeaderAuthorization = "Authorization"
View Source
const HeaderCacheControl = "Cache-Control"
View Source
const HeaderContentLength = "Content-Length"
View Source
const HeaderContentType = "Content-Type"
View Source
const HeaderUserAgent = "User-Agent"
View Source
const HeaderXForwardedFor = "X-Forwarded-For"
View Source
const HeaderXRequestID = "X-Request-Id"
View Source
const StatusAccepted = 202
View Source
const StatusBadGateway = 502
View Source
const StatusBadRequest = 400
View Source
const StatusConflict = 409
View Source
const StatusCreated = 201
View Source
const StatusForbidden = 403
View Source
const StatusFound = 302
View Source
const StatusGatewayTimeout = 504
View Source
const StatusGone = 410
View Source
const StatusInternalServerError = 500
View Source
const StatusMethodNotAllowed = 405
View Source
const StatusMovedPermanently = 301
View Source
const StatusNoContent = 204
View Source
const StatusNotFound = 404
View Source
const StatusNotModified = 304
View Source
const StatusOK = 200
View Source
const StatusTooManyRequests = 429
View Source
const StatusUnprocessableEntity = 422
Variables ¶
This section is empty.
Functions ¶
func GetQueryParamOr ¶
func JSONBadRequest ¶
func JSONBadRequest(w http.ResponseWriter, message string) error
func JSONCreated ¶
func JSONCreated(w http.ResponseWriter, value any) error
func JSONForbidden ¶
func JSONForbidden(w http.ResponseWriter, message string) error
func JSONInternalError ¶
func JSONInternalError(w http.ResponseWriter, message string) error
func JSONNotFound ¶
func JSONNotFound(w http.ResponseWriter, message string) error
func JSONStatus ¶
func JSONStatus(w http.ResponseWriter, value any, status int) error
func JSONUnauthorized ¶
func JSONUnauthorized(w http.ResponseWriter, message string) error
func MethodNotAllowed ¶
func MethodNotAllowed(w http.ResponseWriter, allowed ...string)
func NoContent ¶
func NoContent(w http.ResponseWriter)
func ReadJSONLimit ¶ added in v0.0.8
func RedirectPermanent ¶
func RedirectPermanent(w http.ResponseWriter, r *http.Request, url string)
func SafeRedirect ¶ added in v0.0.8
func SetSecureHeaders ¶ added in v0.0.8
func SetSecureHeaders(w http.ResponseWriter)
func TextStatus ¶
func TextStatus(w http.ResponseWriter, content string, status int) error
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.