http

package
v0.0.14-dev Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HeaderAccept         = "Accept"
	HeaderCharset        = "Accept-Charset"
	HeaderAcceptEncoding = "Accept-Encoding"
	HeaderAcceptLanguage = "Accept-Language"
	HeaderAcceptPatch    = "Accept-Patch"
	HeaderAcceptRanges   = "Accept-Ranges"

	HeaderAccessControlAllowCredentials = "Access-Control-Allow-Credentials"
	HeaderAccessControlAllowHeaders     = "Access-Control-Allow-Headers"
	HeaderAccessControlAllowMethods     = "Access-Control-Allow-Methods"
	HeaderAccessControlAllowOrigin      = "Access-Control-Allow-Origin"
	HeaderAccessControlExposeHeaders    = "Access-Control-Expose-Headers"
	HeaderAccessControlMaxAge           = "Access-Control-Max-Age"
	HeaderAccessControlRequestHeaders   = "Access-Control-Request-Headers"
	HeaderAccessControlRequestMethod    = "Access-Control-Request-Method"

	HeaderAge                = "Age"
	HeaderAllow              = "Allow"
	HeaderAuthorization      = "Authorization"
	HeaderCacheControl       = "Cache-Control"
	HeaderConnection         = "Connection"
	HeaderContentDisposition = "Content-Disposition"
	HeaderContentEncoding    = "Content-Encoding"
	HeaderContentLanguage    = "Content-Language"
	HeaderContentLength      = "Content-Length"
	HeaderContentType        = "Content-Type"
	HeaderCookie             = "Cookie"
	HeaderDate               = "Date"
	HeaderETag               = "ETag"
	HeaderExpect             = "Expect"
	HeaderExpires            = "Expires"
	HeaderFrom               = "From"
	HeaderHost               = "Host"

	HeaderIfMatch            = "If-Match"
	HeaderIfModifiedSince    = "If-Modified-Since"
	HeaderIfNoneMatch        = "If-None-Match"
	HeaderIfRange            = "If-Range"
	HeaderIfUnmodifiedSince  = "If-Unmodified-Since"
	HeaderLastModified       = "Last-Modified"
	HeaderLink               = "Link"
	HeaderLocation           = "Location"
	HeaderMaxForwards        = "Max-Forwards"
	HeaderOrigin             = "Origin"
	HeaderPragma             = "Pragma"
	HeaderProxyAuthenticate  = "Proxy-Authenticate"
	HeaderProxyAuthorization = "Proxy-Authorization"
	HeaderRange              = "Range"
	HeaderReferer            = "Referer"
	HeaderRetryAfter         = "Retry-After"
	HeaderServer             = "Server"
	HeaderSetCookie          = "Set-Cookie"
	HeaderSetCookie2         = "Set-Cookie2"
	HeaderTE                 = "TE"
	HeaderTrailer            = "Trailer"
	HeaderTransferEncoding   = "TransferEncoding"
	HeaderUpgrade            = "Upgrade"
	HeaderUserAgent          = "UserAgent"
	HeaderVary               = "Vary"
	HeaderVia                = "Via"
	HeaderWarning            = "Warning"
	HeaderWWWAuthenticate    = "WWW-Authenticate"
)
View Source
const (
	PathVariablesAttribute = "PathVariables"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context interface {
	context.Context

	IsCompleted() bool
	Abort()
	IsAborted() bool
	Request() Request
	Response() Response
}

func NewContext

func NewContext(request Request, response Response) Context

func WithRequest

func WithRequest(parent Context, request Request) Context

func WithResponse

func WithResponse(parent Context, response Response) Context

func WithValue

func WithValue(parent Context, key, val any) Context
type Cookie struct {
	Name  string
	Value string

	Path    string
	Domain  string
	Expires time.Time

	MaxAge   int
	Secure   bool
	HttpOnly bool
	SameSite SameSite
}

type ErrorHandler

type ErrorHandler interface {
	HandleError(ctx Context, err error)
}

type Flushable

type Flushable interface {
	Flush() error
}

type Handler

type Handler interface {
	Invoke(ctx Context) (any, error)
}

func Handle

func Handle(fn func(ctx Context) error) Handler

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 MediaType

type MediaType string
const (
	MediaTypeAll               MediaType = "*/*"
	MediaTypeAtomXml           MediaType = "application/atom+xml"
	MediaTypeCbor              MediaType = "application/cbor"
	MediaTypeFormUrlencoded    MediaType = "application/x-www-form-urlencoded"
	MediaTypeGraphqlResponse   MediaType = "application/graphql-response+json"
	MediaTypeJson              MediaType = "application/json"
	MediaTypeJsonUtf8          MediaType = "application/json;charset=UTF-8"
	MediaTypeYaml              MediaType = "application/yaml"
	MediaTypeYamlUtf8          MediaType = "application/yaml;charset=UTF-8"
	MediaTypeOctetStream       MediaType = "application/octet-stream"
	MediaTypePdf               MediaType = "application/pdf"
	MediaTypeProblemJson       MediaType = "application/problem+json"
	MediaTypeProblemJsonUtf8   MediaType = "application/problem+json;charset=UTF-8"
	MediaTypeProblemXml        MediaType = "application/problem+xml"
	MediaTypeProtobuf          MediaType = "application/x-protobuf"
	MediaTypeRssXml            MediaType = "application/rss+xml"
	MediaTypeStreamJson        MediaType = "application/stream+json"
	MediaTypeXhtmlXml          MediaType = "application/xhtml+xml"
	MediaTypeXml               MediaType = "application/xml"
	MediaTypeImageGif          MediaType = "image/gif"
	MediaTypeImageJpeg         MediaType = "image/jpeg"
	MediaTypeImagePng          MediaType = "image/png"
	MediaTypeMultipartFormData MediaType = "multipart/form-data"
	MediaTypeMultipartMixed    MediaType = "multipart/mixed"
	MediaTypeMultipartRelated  MediaType = "multipart/related"
	MediaTypeTextEventStream   MediaType = "text/event-stream"
	MediaTypeTextHtml          MediaType = "text/html"
	MediaTypeTextMarkdown      MediaType = "text/markdown"
	MediaTypeTextPlain         MediaType = "text/plain"
	MediaTypeTextXml           MediaType = "text/xml"
)

func (MediaType) Charset

func (m MediaType) Charset() string

func (MediaType) IsWildcardSubtype

func (m MediaType) IsWildcardSubtype() bool

func (MediaType) IsWildcardType

func (m MediaType) IsWildcardType() bool

func (MediaType) Parameter

func (m MediaType) Parameter(name string) (string, bool)

func (MediaType) Subtype

func (m MediaType) Subtype() string

func (MediaType) Type

func (m MediaType) Type() string

type Method

type Method string
const (
	MethodGet     Method = "GET"
	MethodHead    Method = "HEAD"
	MethodPost    Method = "POST"
	MethodPut     Method = "PUT"
	MethodPatch   Method = "PATCH" // RFC 5789
	MethodDelete  Method = "DELETE"
	MethodConnect Method = "CONNECT"
	MethodOptions Method = "OPTIONS"
	MethodTrace   Method = "TRACE"
)

func (Method) IntValue

func (m Method) IntValue() int

type MultiReadRequest

type MultiReadRequest struct {
	// contains filtered or unexported fields
}

func NewMultiReadRequest

func NewMultiReadRequest(request Request) *MultiReadRequest

func (*MultiReadRequest) Context

func (m *MultiReadRequest) Context() Context

func (*MultiReadRequest) Cookie

func (m *MultiReadRequest) Cookie(name string) (*Cookie, bool)

func (*MultiReadRequest) Cookies

func (m *MultiReadRequest) Cookies() []*Cookie

func (*MultiReadRequest) Header

func (m *MultiReadRequest) Header(name string) (string, bool)

func (*MultiReadRequest) HeaderNames

func (m *MultiReadRequest) HeaderNames() []string

func (*MultiReadRequest) Headers

func (m *MultiReadRequest) Headers(name string) []string

func (*MultiReadRequest) IsSecure

func (m *MultiReadRequest) IsSecure() bool

func (*MultiReadRequest) Method

func (m *MultiReadRequest) Method() Method

func (*MultiReadRequest) Parameter

func (m *MultiReadRequest) Parameter(name string) (string, bool)

func (*MultiReadRequest) ParameterNames

func (m *MultiReadRequest) ParameterNames() []string

func (*MultiReadRequest) Parameters

func (m *MultiReadRequest) Parameters(name string) []string

func (*MultiReadRequest) Path

func (m *MultiReadRequest) Path() string

func (*MultiReadRequest) QueryString

func (m *MultiReadRequest) QueryString() string

func (*MultiReadRequest) Reader

func (m *MultiReadRequest) Reader() io.Reader

func (*MultiReadRequest) Scheme

func (m *MultiReadRequest) Scheme() string

type MultiReadResponse

type MultiReadResponse struct {
	// contains filtered or unexported fields
}

func NewMultiReadResponse

func NewMultiReadResponse(response Response) *MultiReadResponse

func (*MultiReadResponse) AddCookie

func (m *MultiReadResponse) AddCookie(cookie *Cookie)

func (*MultiReadResponse) AddHeader

func (m *MultiReadResponse) AddHeader(name string, value string)

func (*MultiReadResponse) CharacterEncoding

func (m *MultiReadResponse) CharacterEncoding() string

func (*MultiReadResponse) ContentLength

func (m *MultiReadResponse) ContentLength() int

func (*MultiReadResponse) ContentType

func (m *MultiReadResponse) ContentType() string

func (*MultiReadResponse) Context

func (m *MultiReadResponse) Context() Context

func (*MultiReadResponse) CopyBodyToResponse

func (m *MultiReadResponse) CopyBodyToResponse() error

func (*MultiReadResponse) DeleteHeader

func (m *MultiReadResponse) DeleteHeader(name string)

func (*MultiReadResponse) Flush

func (m *MultiReadResponse) Flush() error

func (*MultiReadResponse) Header

func (m *MultiReadResponse) Header(name string) (string, bool)

func (*MultiReadResponse) HeaderNames

func (m *MultiReadResponse) HeaderNames() []string

func (*MultiReadResponse) Headers

func (m *MultiReadResponse) Headers(name string) []string

func (*MultiReadResponse) IsCommitted

func (m *MultiReadResponse) IsCommitted() bool

func (*MultiReadResponse) Reset

func (m *MultiReadResponse) Reset()

func (*MultiReadResponse) SetCharacterEncoding

func (m *MultiReadResponse) SetCharacterEncoding(charset string)

func (*MultiReadResponse) SetContentLength

func (m *MultiReadResponse) SetContentLength(len int)

func (*MultiReadResponse) SetContentType

func (m *MultiReadResponse) SetContentType(contentType string)

func (*MultiReadResponse) SetHeader

func (m *MultiReadResponse) SetHeader(name string, value string)

func (*MultiReadResponse) SetStatus

func (m *MultiReadResponse) SetStatus(status Status)

func (*MultiReadResponse) Status

func (m *MultiReadResponse) Status() Status

func (*MultiReadResponse) Writer

func (m *MultiReadResponse) Writer() io.Writer

type NotFoundError

type NotFoundError struct {
}

func (NotFoundError) Error

func (e NotFoundError) Error() string

type PathVariable

type PathVariable struct {
	Name  string
	Value string
}

type PathVariables

type PathVariables struct {
	// contains filtered or unexported fields
}

func (*PathVariables) Put

func (p *PathVariables) Put(name string, value string)

func (*PathVariables) Value

func (p *PathVariables) Value(name string) (string, bool)

type Request

type Request interface {
	Context() Context

	Cookie(name string) (*Cookie, bool)
	Cookies() []*Cookie

	Parameter(name string) (string, bool)
	ParameterNames() []string
	Parameters(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 {
	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, bool)
	HeaderNames() []string
	Headers(name string) []string
	Status() Status
	SetStatus(status Status)

	Writer() io.Writer
	Flush() error
	IsCommitted() bool
	Reset()
}

type ReturnValueHandler

type ReturnValueHandler interface {
	SupportsReturnType(returnType reflect.Type) bool
	HandleReturnValue(ctx Context, returnValue any) error
}

type SameSite

type SameSite int
const (
	SameSiteDefaultMode SameSite = iota + 1
	SameSiteLaxMode
	SameSiteStrictMode
	SameSiteNoneMode
)

type Server

type Server interface {
	runtime.Server
}

type Status

type Status int
const (
	StatusContinue           Status = 100
	StatusSwitchingProtocols Status = 101
	StatusProcessing         Status = 102
	StatusEarlyHints         Status = 103

	StatusOK                   Status = 200
	StatusCreated              Status = 201
	StatusAccepted             Status = 202
	StatusNonAuthoritativeInfo Status = 203
	StatusNoContent            Status = 204
	StatusResetContent         Status = 205
	StatusPartialContent       Status = 206
	StatusMultiStatus          Status = 207
	StatusAlreadyReported      Status = 208
	StatusIMUsed               Status = 226

	StatusMultipleChoices  Status = 300
	StatusMovedPermanently Status = 301
	StatusFound            Status = 302
	StatusSeeOther         Status = 303
	StatusNotModified      Status = 304
	StatusUseProxy         Status = 305

	StatusTemporaryRedirect Status = 307
	StatusPermanentRedirect Status = 308

	StatusBadRequest                   Status = 400
	StatusUnauthorized                 Status = 401
	StatusPaymentRequired              Status = 402
	StatusForbidden                    Status = 403
	StatusNotFound                     Status = 404
	StatusMethodNotAllowed             Status = 405
	StatusNotAcceptable                Status = 406
	StatusProxyAuthRequired            Status = 407
	StatusRequestTimeout               Status = 408
	StatusConflict                     Status = 409
	StatusGone                         Status = 410
	StatusLengthRequired               Status = 411
	StatusPreconditionFailed           Status = 412
	StatusRequestEntityTooLarge        Status = 413
	StatusRequestURITooLong            Status = 414
	StatusUnsupportedMediaType         Status = 415
	StatusRequestedRangeNotSatisfiable Status = 416
	StatusExpectationFailed            Status = 417
	StatusTeapot                       Status = 418
	StatusMisdirectedRequest           Status = 421
	StatusUnprocessableEntity          Status = 422
	StatusLocked                       Status = 423
	StatusFailedDependency             Status = 424
	StatusTooEarly                     Status = 425
	StatusUpgradeRequired              Status = 426
	StatusPreconditionRequired         Status = 428
	StatusTooManyRequests              Status = 429
	StatusRequestHeaderFieldsTooLarge  Status = 431
	StatusUnavailableForLegalReasons   Status = 451

	StatusInternalServerError           Status = 500
	StatusNotImplemented                Status = 501
	StatusBadGateway                    Status = 502
	StatusServiceUnavailable            Status = 503
	StatusGatewayTimeout                Status = 504
	StatusHTTPVersionNotSupported       Status = 505
	StatusVariantAlsoNegotiates         Status = 506
	StatusInsufficientStorage           Status = 507
	StatusLoopDetected                  Status = 508
	StatusNotExtended                   Status = 510
	StatusNetworkAuthenticationRequired Status = 511
)

func (Status) String

func (code Status) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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