http

package
v0.0.21 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

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 StatusServiceUnavailable = 503
View Source
const StatusTooManyRequests = 429
View Source
const StatusUnauthorized = 401
View Source
const StatusUnprocessableEntity = 422

Variables

This section is empty.

Functions

func GetHeader

func GetHeader(r *http.Request, key string) string

func GetHeaderOr

func GetHeaderOr(r *http.Request, key string, defaultValue string) string

func GetQueryBool

func GetQueryBool(r *http.Request, key string) (bool, error)

func GetQueryBoolOr

func GetQueryBoolOr(r *http.Request, key string, defaultValue bool) bool

func GetQueryInt

func GetQueryInt(r *http.Request, key string) (int, error)

func GetQueryIntOr

func GetQueryIntOr(r *http.Request, key string, defaultValue int) int

func GetQueryParam

func GetQueryParam(r *http.Request, key string) string

func GetQueryParamOr

func GetQueryParamOr(r *http.Request, key string, defaultValue string) string

func HTML

func HTML(w http.ResponseWriter, content string) error

func IsDelete

func IsDelete(r *http.Request) bool

func IsGet

func IsGet(r *http.Request) bool

func IsPatch

func IsPatch(r *http.Request) bool

func IsPost

func IsPost(r *http.Request) bool

func IsPut

func IsPut(r *http.Request) bool

func JSON

func JSON(w http.ResponseWriter, value any) error

func JSONBadRequest

func JSONBadRequest(w http.ResponseWriter, message string) error

func JSONCreated

func JSONCreated(w http.ResponseWriter, value any) error

func JSONError

func JSONError(w http.ResponseWriter, message string, status int) 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 ReadJSON

func ReadJSON(r *http.Request, target any) error

func ReadJSONAndClose

func ReadJSONAndClose(r *http.Request, target any) error

func ReadJSONLimit added in v0.0.8

func ReadJSONLimit(r *http.Request, maxBytes int64, target any) error

func Redirect

func Redirect(w http.ResponseWriter, r *http.Request, url string)

func RedirectPermanent

func RedirectPermanent(w http.ResponseWriter, r *http.Request, url string)

func SafeHTML added in v0.0.8

func SafeHTML(w http.ResponseWriter, content string) error

func SafeRedirect added in v0.0.8

func SafeRedirect(w http.ResponseWriter, r *http.Request, redirectURL string, allowedHosts ...string) error

func SafeURL added in v0.0.5

func SafeURL(tmpl string, pathParams map[string]string, queryParams map[string]string) (string, error)

func SecureHeaders added in v0.0.8

func SecureHeaders(handler http.Handler) http.Handler

func Serve

func Serve(addr string, handler http.Handler) error

func SetSecureHeaders added in v0.0.8

func SetSecureHeaders(w http.ResponseWriter)

func Text

func Text(w http.ResponseWriter, content string) error

func TextStatus

func TextStatus(w http.ResponseWriter, content string, status int) error

func WithCSRF

func WithCSRF(handler http.Handler) http.Handler

Types

This section is empty.

Jump to

Keyboard shortcuts

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