Documentation ¶
Overview ¶
Package recv defines a pure computations to compose HTTP response receivers
Index ¶
- Constants
- func Body[T any](out *T) http.Arrow
- func Bytes(w io.Writer) http.Arrow
- func Code(code ...http.StatusCode) http.Arrow
- func Expect[T any](expect T) http.Arrow
- func Header[T http.MatchableHeaderValues](header string, value T) http.Arrow
- func Match(val string) http.Arrow
- func Recv[T any](out *T) http.Arrow
- func Try(arrow http.Arrow) http.Arrow
- type HeaderEnumConnection
- func (h HeaderEnumConnection) Any(ctx *http.Context) error
- func (h HeaderEnumConnection) Close(ctx *http.Context) error
- func (h HeaderEnumConnection) Is(value string) http.Arrow
- func (h HeaderEnumConnection) KeepAlive(ctx *http.Context) error
- func (h HeaderEnumConnection) To(value *string) http.Arrow
- type HeaderEnumContent
- func (h HeaderEnumContent) Any(ctx *http.Context) error
- func (h HeaderEnumContent) ApplicationJSON(ctx *http.Context) error
- func (h HeaderEnumContent) Form(ctx *http.Context) error
- func (h HeaderEnumContent) HTML(ctx *http.Context) error
- func (h HeaderEnumContent) Is(value string) http.Arrow
- func (h HeaderEnumContent) JSON(ctx *http.Context) error
- func (h HeaderEnumContent) Text(ctx *http.Context) error
- func (h HeaderEnumContent) TextHTML(ctx *http.Context) error
- func (h HeaderEnumContent) TextPlain(ctx *http.Context) error
- func (h HeaderEnumContent) To(value *string) http.Arrow
- type HeaderEnumTransferEncoding
- func (h HeaderEnumTransferEncoding) Any(ctx *http.Context) error
- func (h HeaderEnumTransferEncoding) Chunked(ctx *http.Context) error
- func (h HeaderEnumTransferEncoding) Identity(ctx *http.Context) error
- func (h HeaderEnumTransferEncoding) Is(value string) http.Arrow
- func (h HeaderEnumTransferEncoding) To(value *string) http.Arrow
- type HeaderOf
- type StatusCode
- func (code StatusCode) Accepted(cat *http.Context) error
- func (code StatusCode) BadGateway(cat *http.Context) error
- func (code StatusCode) BadRequest(cat *http.Context) error
- func (code StatusCode) Conflict(cat *http.Context) error
- func (code StatusCode) Created(cat *http.Context) error
- func (code StatusCode) Forbidden(cat *http.Context) error
- func (code StatusCode) Found(cat *http.Context) error
- func (code StatusCode) GatewayTimeout(cat *http.Context) error
- func (code StatusCode) Gone(cat *http.Context) error
- func (code StatusCode) HTTPVersionNotSupported(cat *http.Context) error
- func (code StatusCode) InternalServerError(cat *http.Context) error
- func (code StatusCode) LengthRequired(cat *http.Context) error
- func (code StatusCode) MethodNotAllowed(cat *http.Context) error
- func (code StatusCode) MovedPermanently(cat *http.Context) error
- func (code StatusCode) MultipleChoices(cat *http.Context) error
- func (code StatusCode) NoContent(cat *http.Context) error
- func (code StatusCode) NonAuthoritativeInfo(cat *http.Context) error
- func (code StatusCode) NotAcceptable(cat *http.Context) error
- func (code StatusCode) NotFound(cat *http.Context) error
- func (code StatusCode) NotImplemented(cat *http.Context) error
- func (code StatusCode) NotModified(cat *http.Context) error
- func (code StatusCode) OK(cat *http.Context) error
- func (code StatusCode) PaymentRequired(cat *http.Context) error
- func (code StatusCode) PreconditionFailed(cat *http.Context) error
- func (code StatusCode) ProxyAuthRequired(cat *http.Context) error
- func (code StatusCode) RequestEntityTooLarge(cat *http.Context) error
- func (code StatusCode) RequestTimeout(cat *http.Context) error
- func (code StatusCode) RequestURITooLong(cat *http.Context) error
- func (code StatusCode) ResetContent(cat *http.Context) error
- func (code StatusCode) SeeOther(cat *http.Context) error
- func (code StatusCode) ServiceUnavailable(cat *http.Context) error
- func (code StatusCode) Unauthorized(cat *http.Context) error
- func (code StatusCode) UnsupportedMediaType(cat *http.Context) error
- func (code StatusCode) UseProxy(cat *http.Context) error
Constants ¶
const ( Age = HeaderOf[int]("Age") CacheControl = HeaderOf[string]("Cache-Control") Connection = HeaderEnumConnection("Connection") ContentEncoding = HeaderOf[string]("Content-Encoding") ContentLanguage = HeaderOf[string]("Content-Language") ContentLength = HeaderOf[int]("Content-Length") ContentLocation = HeaderOf[string]("Content-Location") ContentMD5 = HeaderOf[string]("Content-MD5") ContentRange = HeaderOf[string]("Content-Range") ContentType = HeaderEnumContent("Content-Type") Date = HeaderOf[time.Time]("Date") ETag = HeaderOf[string]("ETag") Expires = HeaderOf[time.Time]("Expires") LastModified = HeaderOf[time.Time]("Last-Modified") Link = HeaderOf[string]("Link") Location = HeaderOf[string]("Location") RetryAfter = HeaderOf[time.Time]("Retry-After") Server = HeaderOf[string]("Server") SetCookie = HeaderOf[string]("Set-Cookie") TransferEncoding = HeaderEnumTransferEncoding("Transfer-Encoding") Via = HeaderOf[string]("Via") )
List of supported HTTP header constants https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#Response_fields
const Status = StatusCode(0)
Status is collection of constants for HTTP Status Code checks
ƒ.Status.OK ƒ.Status.NotFound
Variables ¶
This section is empty.
Functions ¶
func Body ¶ added in v2.5.0
Body applies auto decoders for response and returns either binary or native Go data structure. The Content-Type header give a hint to decoder. Supply the pointer to data target data structure.
func Code ¶
func Code(code ...http.StatusCode) http.Arrow
Code is a mandatory statement to match expected HTTP Status Code against received one. The execution fails StatusCode error if service responds with other value then specified one.
func Header ¶
func Header[T http.MatchableHeaderValues](header string, value T) http.Arrow
Header matches or lifts header value
Types ¶
type HeaderEnumConnection ¶
type HeaderEnumConnection string
Type of HTTP Header, Connection enumeration
const Connection = HeaderEnumConnection("Connection") ƒ.Connection.KeepAlive
func (HeaderEnumConnection) Any ¶
func (h HeaderEnumConnection) Any(ctx *http.Context) error
Matches header to any value
func (HeaderEnumConnection) Close ¶
func (h HeaderEnumConnection) Close(ctx *http.Context) error
Close defines header `???: close`
func (HeaderEnumConnection) Is ¶
func (h HeaderEnumConnection) Is(value string) http.Arrow
Matches value of HTTP header
type HeaderEnumContent ¶
type HeaderEnumContent string
Type of HTTP Header, Content-Type enumeration
const ContentType = HeaderEnumContent("Content-Type") ƒ.ContentType.JSON
func (HeaderEnumContent) Any ¶
func (h HeaderEnumContent) Any(ctx *http.Context) error
Matches header to any value
func (HeaderEnumContent) ApplicationJSON ¶
func (h HeaderEnumContent) ApplicationJSON(ctx *http.Context) error
ApplicationJSON defines header `???: application/json`
func (HeaderEnumContent) Form ¶
func (h HeaderEnumContent) Form(ctx *http.Context) error
Form defined Header `???: application/x-www-form-urlencoded`
func (HeaderEnumContent) HTML ¶
func (h HeaderEnumContent) HTML(ctx *http.Context) error
HTML defined Header `???: text/html`
func (HeaderEnumContent) Is ¶
func (h HeaderEnumContent) Is(value string) http.Arrow
Matches value of HTTP header
func (HeaderEnumContent) JSON ¶
func (h HeaderEnumContent) JSON(ctx *http.Context) error
JSON defines header `???: application/json`
func (HeaderEnumContent) Text ¶
func (h HeaderEnumContent) Text(ctx *http.Context) error
Text defined Header `???: text/plain`
func (HeaderEnumContent) TextHTML ¶
func (h HeaderEnumContent) TextHTML(ctx *http.Context) error
TextHTML defined Header `???: text/html`
type HeaderEnumTransferEncoding ¶
type HeaderEnumTransferEncoding string
Type of HTTP Header, Transfer-Encoding enumeration
const TransferEncoding = HeaderEnumTransferEncoding("Transfer-Encoding") ƒ.TransferEncoding.Chunked
func (HeaderEnumTransferEncoding) Any ¶
func (h HeaderEnumTransferEncoding) Any(ctx *http.Context) error
Matches header to any value
func (HeaderEnumTransferEncoding) Chunked ¶
func (h HeaderEnumTransferEncoding) Chunked(ctx *http.Context) error
Chunked defines header `Transfer-Encoding: chunked`
func (HeaderEnumTransferEncoding) Identity ¶
func (h HeaderEnumTransferEncoding) Identity(ctx *http.Context) error
Identity defines header `Transfer-Encoding: identity`
type HeaderOf ¶
type HeaderOf[T http.ReadableHeaderValues] string
Header matches presence of header in the response or match its entire content. The execution fails with BadMatchHead if the matched value do not meet expectations.
http.Join( ... ƒ.ContentType.JSON, ƒ.ContentEncoding.Is(...), )
type StatusCode ¶
type StatusCode int
StatusCode is a warpper type over http.StatusCode
http.Join( ... ƒ.Code(http.StatusOK), )
so that response code is matched using constant
http.Join( ... ƒ.Status.OK, )
func (StatusCode) Accepted ¶
func (code StatusCode) Accepted(cat *http.Context) error
Accepted ⟼ http.StatusAccepted
func (StatusCode) BadGateway ¶
func (code StatusCode) BadGateway(cat *http.Context) error
BadGateway ⟼ http.StatusBadGateway
func (StatusCode) BadRequest ¶
func (code StatusCode) BadRequest(cat *http.Context) error
BadRequest ⟼ http.StatusBadRequest
func (StatusCode) Conflict ¶
func (code StatusCode) Conflict(cat *http.Context) error
Conflict ⟼ http.StatusConflict
func (StatusCode) Created ¶
func (code StatusCode) Created(cat *http.Context) error
Created ⟼ http.StatusCreated
func (StatusCode) Forbidden ¶
func (code StatusCode) Forbidden(cat *http.Context) error
Forbidden ⟼ http.StatusForbidden
func (StatusCode) Found ¶
func (code StatusCode) Found(cat *http.Context) error
Found ⟼ http.StatusFound
func (StatusCode) GatewayTimeout ¶
func (code StatusCode) GatewayTimeout(cat *http.Context) error
GatewayTimeout ⟼ http.StatusGatewayTimeout
func (StatusCode) Gone ¶
func (code StatusCode) Gone(cat *http.Context) error
Gone ⟼ http.StatusGone
func (StatusCode) HTTPVersionNotSupported ¶
func (code StatusCode) HTTPVersionNotSupported(cat *http.Context) error
HTTPVersionNotSupported ⟼ http.StatusHTTPVersionNotSupported
func (StatusCode) InternalServerError ¶
func (code StatusCode) InternalServerError(cat *http.Context) error
InternalServerError ⟼ http.StatusInternalServerError
func (StatusCode) LengthRequired ¶
func (code StatusCode) LengthRequired(cat *http.Context) error
LengthRequired ⟼ http.StatusLengthRequired
func (StatusCode) MethodNotAllowed ¶
func (code StatusCode) MethodNotAllowed(cat *http.Context) error
MethodNotAllowed ⟼ http.StatusMethodNotAllowed
func (StatusCode) MovedPermanently ¶
func (code StatusCode) MovedPermanently(cat *http.Context) error
MovedPermanently ⟼ http.StatusMovedPermanently
func (StatusCode) MultipleChoices ¶
func (code StatusCode) MultipleChoices(cat *http.Context) error
MultipleChoices ⟼ http.StatusMultipleChoices
func (StatusCode) NoContent ¶
func (code StatusCode) NoContent(cat *http.Context) error
NoContent ⟼ http.StatusNoContent
func (StatusCode) NonAuthoritativeInfo ¶
func (code StatusCode) NonAuthoritativeInfo(cat *http.Context) error
NonAuthoritativeInfo ⟼ http.StatusNonAuthoritativeInfo
func (StatusCode) NotAcceptable ¶
func (code StatusCode) NotAcceptable(cat *http.Context) error
NotAcceptable ⟼ http.StatusNotAcceptable
func (StatusCode) NotFound ¶
func (code StatusCode) NotFound(cat *http.Context) error
NotFound ⟼ http.StatusNotFound
func (StatusCode) NotImplemented ¶
func (code StatusCode) NotImplemented(cat *http.Context) error
NotImplemented ⟼ http.StatusNotImplemented
func (StatusCode) NotModified ¶
func (code StatusCode) NotModified(cat *http.Context) error
NotModified ⟼ http.StatusNotModified
func (StatusCode) PaymentRequired ¶
func (code StatusCode) PaymentRequired(cat *http.Context) error
PaymentRequired ⟼ http.StatusPaymentRequired
func (StatusCode) PreconditionFailed ¶
func (code StatusCode) PreconditionFailed(cat *http.Context) error
PreconditionFailed ⟼ http.StatusPreconditionFailed
func (StatusCode) ProxyAuthRequired ¶
func (code StatusCode) ProxyAuthRequired(cat *http.Context) error
ProxyAuthRequired ⟼ http.StatusProxyAuthRequired
func (StatusCode) RequestEntityTooLarge ¶
func (code StatusCode) RequestEntityTooLarge(cat *http.Context) error
RequestEntityTooLarge ⟼ http.StatusRequestEntityTooLarge
func (StatusCode) RequestTimeout ¶
func (code StatusCode) RequestTimeout(cat *http.Context) error
RequestTimeout ⟼ http.StatusRequestTimeout
func (StatusCode) RequestURITooLong ¶
func (code StatusCode) RequestURITooLong(cat *http.Context) error
RequestURITooLong ⟼ http.StatusRequestURITooLong
func (StatusCode) ResetContent ¶
func (code StatusCode) ResetContent(cat *http.Context) error
ResetContent ⟼ http.StatusResetContent
func (StatusCode) SeeOther ¶
func (code StatusCode) SeeOther(cat *http.Context) error
SeeOther ⟼ http.StatusSeeOther
func (StatusCode) ServiceUnavailable ¶
func (code StatusCode) ServiceUnavailable(cat *http.Context) error
ServiceUnavailable ⟼ http.StatusServiceUnavailable
func (StatusCode) Unauthorized ¶
func (code StatusCode) Unauthorized(cat *http.Context) error
Unauthorized ⟼ http.StatusUnauthorized
func (StatusCode) UnsupportedMediaType ¶
func (code StatusCode) UnsupportedMediaType(cat *http.Context) error
UnsupportedMediaType ⟼ http.StatusUnsupportedMediaType