Documentation ¶
Index ¶
- Constants
- func SetCookie(w http.ResponseWriter, cookie *Cookie)
- type Context
- type Cookie
- type ErrorHandler
- type Handler
- type HandlerChain
- type HandlerFunction
- type HandlerWrapper
- type Method
- type NotFoundError
- type PathVariable
- type PathVariables
- type Request
- type RequestDelegate
- type Response
- type ReturnValueHandler
- type SameSite
- type Status
Constants ¶
View Source
const (
PathVariablesAttribute = "PathVariables"
)
Variables ¶
This section is empty.
Functions ¶
func SetCookie ¶
func SetCookie(w http.ResponseWriter, cookie *Cookie)
SetCookie adds a Set-Cookie header to the provided ResponseWriter's headers. The provided cookie must have a valid Name. Invalid cookies may be silently dropped.
Types ¶
type Cookie ¶
type Cookie struct { Name string Value string Path string // optional Domain string // optional Expires time.Time // optional RawExpires string // for reading cookies only // MaxAge=0 means no 'Max-Age' attribute specified. // MaxAge<0 means delete cookie now, equivalently 'Max-Age: 0' // MaxAge>0 means Max-Age attribute present and given in seconds MaxAge int Secure bool HttpOnly bool SameSite SameSite Raw string Unparsed []string // Raw text of unparsed attribute-value pairs }
type ErrorHandler ¶
type HandlerChain ¶
type HandlerChain []HandlerFunction
type HandlerFunction ¶
type HandlerFunction func(ctx Context, next RequestDelegate) error
type HandlerWrapper ¶
type HandlerWrapper struct {
// contains filtered or unexported fields
}
func WrapHandler ¶
func WrapHandler(handler Handler) *HandlerWrapper
func (*HandlerWrapper) Invoke ¶
func (w *HandlerWrapper) Invoke(ctx Context, next RequestDelegate) error
func (*HandlerWrapper) SetReturnValueHandlers ¶
func (w *HandlerWrapper) SetReturnValueHandlers(handlers []ReturnValueHandler)
func (*HandlerWrapper) Unwrap ¶
func (w *HandlerWrapper) Unwrap() Handler
type NotFoundError ¶
type NotFoundError struct { }
func (NotFoundError) Error ¶
func (e NotFoundError) Error() string
type PathVariable ¶
type PathVariables ¶
type PathVariables struct {
// contains filtered or unexported fields
}
func (*PathVariables) Put ¶
func (p *PathVariables) Put(name string, value string)
type Request ¶
type Request interface { WithReader(reader io.Reader) Request Context() Context Cookie(name string) (*Cookie, bool) Cookies() []*Cookie QueryParameter(name string) (string, bool) QueryParameterNames() []string QueryParameters(name string) []string QueryString() string Header(name string) (string, bool) HeaderNames() []string Headers(name string) []string Path() string Method() Method Reader() io.Reader Scheme() string IsSecure() bool }
type RequestDelegate ¶
type RequestDelegate interface {
Invoke(ctx Context)
}
type Response ¶
type Response interface { WithWriter(writer io.Writer) Response Context() Context AddCookie(cookie *Cookie) ContentLength() int SetContentLength(len int) CharacterEncoding() string SetCharacterEncoding(charset string) ContentType() string SetContentType(contentType string) AddHeader(name string, value string) SetHeader(name string, value string) DeleteHeader(name string) Header(name string) string HeaderNames() []string Headers(name string) []string Status() Status SetStatus(status Status) Writer() io.Writer Flush() IsCommitted() bool Reset() }
type ReturnValueHandler ¶
type SameSite ¶
type SameSite int
SameSite allows a server to define a cookie attribute making it impossible for the browser to send this cookie along with cross-site requests. The main goal is to mitigate the risk of cross-origin information leakage, and provide some protection against cross-site request forgery attacks.
See https://tools.ietf.org/html/draft-ietf-httpbis-cookie-same-site-00 for details.
type Status ¶
type Status int
const ( StatusContinue Status = 100 // RFC 9110, 15.2.1 StatusSwitchingProtocols Status = 101 // RFC 9110, 15.2.2 StatusProcessing Status = 102 // RFC 2518, 10.1 StatusEarlyHints Status = 103 // RFC 8297 StatusOK Status = 200 // RFC 9110, 15.3.1 StatusCreated Status = 201 // RFC 9110, 15.3.2 StatusAccepted Status = 202 // RFC 9110, 15.3.3 StatusNonAuthoritativeInfo Status = 203 // RFC 9110, 15.3.4 StatusNoContent Status = 204 // RFC 9110, 15.3.5 StatusResetContent Status = 205 // RFC 9110, 15.3.6 StatusPartialContent Status = 206 // RFC 9110, 15.3.7 StatusMultiStatus Status = 207 // RFC 4918, 11.1 StatusAlreadyReported Status = 208 // RFC 5842, 7.1 StatusIMUsed Status = 226 // RFC 3229, 10.4.1 StatusMultipleChoices Status = 300 // RFC 9110, 15.4.1 StatusMovedPermanently Status = 301 // RFC 9110, 15.4.2 StatusFound Status = 302 // RFC 9110, 15.4.3 StatusSeeOther Status = 303 // RFC 9110, 15.4.4 StatusNotModified Status = 304 // RFC 9110, 15.4.5 StatusUseProxy Status = 305 // RFC 9110, 15.4.6 StatusTemporaryRedirect Status = 307 // RFC 9110, 15.4.8 StatusPermanentRedirect Status = 308 // RFC 9110, 15.4.9 StatusBadRequest Status = 400 // RFC 9110, 15.5.1 StatusPaymentRequired Status = 402 // RFC 9110, 15.5.3 StatusForbidden Status = 403 // RFC 9110, 15.5.4 StatusNotFound Status = 404 // RFC 9110, 15.5.5 StatusMethodNotAllowed Status = 405 // RFC 9110, 15.5.6 StatusNotAcceptable Status = 406 // RFC 9110, 15.5.7 StatusProxyAuthRequired Status = 407 // RFC 9110, 15.5.8 StatusRequestTimeout Status = 408 // RFC 9110, 15.5.9 StatusConflict Status = 409 // RFC 9110, 15.5.10 StatusGone Status = 410 // RFC 9110, 15.5.11 StatusLengthRequired Status = 411 // RFC 9110, 15.5.12 StatusPreconditionFailed Status = 412 // RFC 9110, 15.5.13 StatusRequestEntityTooLarge Status = 413 // RFC 9110, 15.5.14 StatusRequestURITooLong Status = 414 // RFC 9110, 15.5.15 StatusUnsupportedMediaType Status = 415 // RFC 9110, 15.5.16 StatusRequestedRangeNotSatisfiable Status = 416 // RFC 9110, 15.5.17 StatusExpectationFailed Status = 417 // RFC 9110, 15.5.18 StatusTeapot Status = 418 // RFC 9110, 15.5.19 (Unused) StatusMisdirectedRequest Status = 421 // RFC 9110, 15.5.20 StatusUnprocessableEntity Status = 422 // RFC 9110, 15.5.21 StatusLocked Status = 423 // RFC 4918, 11.3 StatusFailedDependency Status = 424 // RFC 4918, 11.4 StatusTooEarly Status = 425 // RFC 8470, 5.2. StatusUpgradeRequired Status = 426 // RFC 9110, 15.5.22 StatusPreconditionRequired Status = 428 // RFC 6585, 3 StatusTooManyRequests Status = 429 // RFC 6585, 4 StatusRequestHeaderFieldsTooLarge Status = 431 // RFC 6585, 5 StatusInternalServerError Status = 500 // RFC 9110, 15.6.1 StatusNotImplemented Status = 501 // RFC 9110, 15.6.2 StatusBadGateway Status = 502 // RFC 9110, 15.6.3 StatusGatewayTimeout Status = 504 // RFC 9110, 15.6.5 StatusHTTPVersionNotSupported Status = 505 // RFC 9110, 15.6.6 StatusVariantAlsoNegotiates Status = 506 // RFC 2295, 8.1 StatusInsufficientStorage Status = 507 // RFC 4918, 11.5 StatusLoopDetected Status = 508 // RFC 5842, 7.2 StatusNotExtended Status = 510 // RFC 2774, 7 StatusNetworkAuthenticationRequired Status = 511 // RFC 6585, 6 )
HTTP status codes as registered with IANA. See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml
Source Files ¶
Click to show internal directories.
Click to hide internal directories.