Documentation
¶
Index ¶
- Constants
- Variables
- func BindForm(r *http.Request, v any, options ...FormOption) error
- func BindJSON(r *http.Request, v any) error
- func BindQuery(r *http.Request, v any, options ...FormOption) error
- func BindValues(values url.Values, v any, options ...FormOption) error
- func BindXML(r *http.Request, v any, options ...XMLOption) error
- func WritXMLBlob(w http.ResponseWriter, code int, data []byte) error
- func WriteBlob(w http.ResponseWriter, code int, contentType string, data []byte) error
- func WriteJSON(w http.ResponseWriter, code int, v any) error
- func WriteJSONBlob(w http.ResponseWriter, code int, data []byte) error
- func WriteNoContent(w http.ResponseWriter, code int) error
- func WriteStream(w http.ResponseWriter, code int, contentType string, reader io.Reader) error
- func WriteString(w http.ResponseWriter, code int, text string) error
- func WriteXML(w http.ResponseWriter, code int, v any) error
- type ErrorEncoderFunc
- type FormOption
- type HTTPError
- type Handler
- type HandlerFunc
- type Middleware
- type XMLOption
Constants ¶
View Source
const ( HeaderAccept = "Accept" HeaderAcceptEncoding = "Accept-Encoding" HeaderAllow = "Allow" HeaderAuthorization = "Authorization" HeaderContentDisposition = "Content-Disposition" HeaderContentEncoding = "Content-Encoding" HeaderContentLength = "Content-Length" HeaderContentType = "Content-Type" HeaderCookie = "Cookie" HeaderSetCookie = "Set-Cookie" HeaderIfModifiedSince = "If-Modified-Since" HeaderLastModified = "Last-Modified" HeaderLocation = "Location" HeaderRetryAfter = "Retry-After" HeaderUpgrade = "Upgrade" HeaderVary = "Vary" HeaderWWWAuthenticate = "WWW-Authenticate" HeaderXForwardedFor = "X-Forwarded-For" HeaderXForwardedProto = "X-Forwarded-Proto" HeaderXForwardedProtocol = "X-Forwarded-Protocol" HeaderXForwardedSsl = "X-Forwarded-Ssl" HeaderXUrlScheme = "X-Url-Scheme" HeaderXHTTPMethodOverride = "X-HTTP-Method-Override" HeaderXRealIP = "X-Real-Ip" HeaderXRequestID = "X-Request-Id" HeaderXCorrelationID = "X-Correlation-Id" HeaderXRequestedWith = "X-Requested-With" HeaderServer = "Server" HeaderOrigin = "Origin" HeaderCacheControl = "Cache-Control" HeaderConnection = "Connection" // Access control HeaderAccessControlRequestMethod = "Access-Control-Request-Method" HeaderAccessControlRequestHeaders = "Access-Control-Request-Headers" HeaderAccessControlAllowOrigin = "Access-Control-Allow-Origin" HeaderAccessControlAllowMethods = "Access-Control-Allow-Methods" HeaderAccessControlAllowHeaders = "Access-Control-Allow-Headers" HeaderAccessControlAllowCredentials = "Access-Control-Allow-Credentials" HeaderAccessControlExposeHeaders = "Access-Control-Expose-Headers" HeaderAccessControlMaxAge = "Access-Control-Max-Age" // Security HeaderStrictTransportSecurity = "Strict-Transport-Security" HeaderXContentTypeOptions = "X-Content-Type-Options" HeaderXXSSProtection = "X-XSS-Protection" HeaderXFrameOptions = "X-Frame-Options" HeaderContentSecurityPolicy = "Content-Security-Policy" HeaderContentSecurityPolicyReportOnly = "Content-Security-Policy-Report-Only" HeaderXCSRFToken = "X-CSRF-Token" HeaderReferrerPolicy = "Referrer-Policy" )
View Source
const ( MimeApplicationJSON = "application/json" MimeApplicationJSONCharsetUTF8 = "application/json; charset=UTF-8" MimeApplicationJavaScript = "application/javascript" MimeApplicationJavaScriptCharsetUTF8 = "application/javascript; charset=UTF-8" MimeApplicationXML = "application/xml" MimeApplicationXMLCharsetUTF8 = "application/xml; charset=UTF-8" MimeTextXML = "text/xml" MimeTextXMLCharsetUTF8 = "text/xml; charset=UTF-8" MimeApplicationForm = "application/x-www-form-urlencoded" MimeApplicationProtobuf = "application/protobuf" MimeApplicationMsgpack = "application/msgpack" MimeTextHTML = "text/html" MimeTextHTMLCharsetUTF8 = "text/html; charset=UTF-8" MimeTextPlain = "text/plain" MimeTextPlainCharsetUTF8 = "text/plain; charset=UTF-8" MimeMultipartForm = "multipart/form-data" MimeOctetStream = "application/octet-stream" )
View Source
const ( TagNameForm = "form" TagNameQuery = "query" TagNameJSON = "json" )
Variables ¶
View Source
var ( ErrBadRequest = NewStatusError(http.StatusBadRequest) ErrPaymentRequired = NewStatusError(http.StatusPaymentRequired) ErrForbidden = NewStatusError(http.StatusForbidden) ErrNotFound = NewStatusError(http.StatusNotFound) ErrMethodNotAllowed = NewStatusError(http.StatusMethodNotAllowed) ErrNotAcceptable = NewStatusError(http.StatusNotAcceptable) ErrProxyAuthRequired = NewStatusError(http.StatusProxyAuthRequired) ErrRequestTimeout = NewStatusError(http.StatusRequestTimeout) ErrConflict = NewStatusError(http.StatusConflict) ErrGone = NewStatusError(http.StatusGone) ErrLengthRequired = NewStatusError(http.StatusLengthRequired) ErrPreconditionFailed = NewStatusError(http.StatusPreconditionFailed) ErrRequestEntityTooLarge = NewStatusError(http.StatusRequestEntityTooLarge) ErrRequestURITooLong = NewStatusError(http.StatusRequestURITooLong) ErrUnsupportedMediaType = NewStatusError(http.StatusUnsupportedMediaType) ErrRequestedRangeNotSatisfiable = NewStatusError(http.StatusRequestedRangeNotSatisfiable) ErrExpectationFailed = NewStatusError(http.StatusExpectationFailed) ErrTeapot = NewStatusError(http.StatusTeapot) ErrMisdirectedRequest = NewStatusError(http.StatusMisdirectedRequest) ErrUnprocessableEntity = NewStatusError(http.StatusUnprocessableEntity) ErrLocked = NewStatusError(http.StatusLocked) ErrFailedDependency = NewStatusError(http.StatusFailedDependency) ErrTooEarly = NewStatusError(http.StatusTooEarly) ErrUpgradeRequired = NewStatusError(http.StatusUpgradeRequired) ErrPreconditionRequired = NewStatusError(http.StatusPreconditionRequired) ErrTooManyRequests = NewStatusError(http.StatusTooManyRequests) ErrRequestHeaderFieldsTooLarge = NewStatusError(http.StatusRequestHeaderFieldsTooLarge) ErrInternalServerError = NewStatusError(http.StatusInternalServerError) ErrNotImplemented = NewStatusError(http.StatusNotImplemented) ErrBadGateway = NewStatusError(http.StatusBadGateway) ErrGatewayTimeout = NewStatusError(http.StatusGatewayTimeout) ErrHTTPVersionNotSupported = NewStatusError(http.StatusHTTPVersionNotSupported) ErrVariantAlsoNegotiates = NewStatusError(http.StatusVariantAlsoNegotiates) ErrInsufficientStorage = NewStatusError(http.StatusInsufficientStorage) ErrLoopDetected = NewStatusError(http.StatusLoopDetected) ErrNotExtended = NewStatusError(http.StatusNotExtended) ErrNetworkAuthenticationRequired = NewStatusError(http.StatusNetworkAuthenticationRequired) )
Functions ¶
func BindValues ¶
func BindValues(values url.Values, v any, options ...FormOption) error
func WritXMLBlob ¶
func WritXMLBlob(w http.ResponseWriter, code int, data []byte) error
func WriteJSONBlob ¶
func WriteJSONBlob(w http.ResponseWriter, code int, data []byte) error
func WriteNoContent ¶
func WriteNoContent(w http.ResponseWriter, code int) error
func WriteStream ¶
func WriteString ¶
func WriteString(w http.ResponseWriter, code int, text string) error
Types ¶
type ErrorEncoderFunc ¶
type ErrorEncoderFunc func(w http.ResponseWriter, r *http.Request, err error)
type FormOption ¶
func WithTagName ¶
func WithTagName(tagName string) FormOption
type HTTPError ¶
type HTTPError struct {
// contains filtered or unexported fields
}
func NewStatusError ¶ added in v0.1.1
func (*HTTPError) WithMessage ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
func NewHandler ¶
func NewHandler(h HandlerFunc) *Handler
func (*Handler) WithErrorEncoder ¶
func (h *Handler) WithErrorEncoder(errorEncoder ErrorEncoderFunc) *Handler
func (*Handler) WithMiddlewares ¶
func (h *Handler) WithMiddlewares(middlewares ...Middleware) *Handler
type HandlerFunc ¶
type HandlerFunc func(w http.ResponseWriter, r *http.Request) error
type Middleware ¶
type Middleware func(next HandlerFunc) HandlerFunc
Source Files
¶
Click to show internal directories.
Click to hide internal directories.