recv

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2022 License: MIT Imports: 7 Imported by: 1

Documentation

Overview

Package recv defines a pure computations to compose HTTP response receivers

Index

Constants

View Source
const (
	CacheControl     = Header("Cache-Control")
	Connection       = Header("Connection")
	ContentEncoding  = Header("Content-Encoding")
	ContentLanguage  = Header("Content-Language")
	ContentLength    = Header("Content-Length")
	ContentType      = Content("Content-Type")
	Date             = Header("Date")
	ETag             = Header("ETag")
	Expires          = Header("Expires")
	LastModified     = Header("Last-Modified")
	Link             = Header("Link")
	Location         = Header("Location")
	Server           = Header("Server")
	SetCookie        = Header("Set-Cookie")
	TransferEncoding = Header("Transfer-Encoding")
)

List of supported HTTP header constants https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#Response_fields

View Source
const Status = StatusCode(0)

Status is collection of constants for HTTP Status Code checks

Variables

This section is empty.

Functions

func Bytes

func Bytes(val *[]byte) http.Arrow

Bytes receive raw binary from HTTP response

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 Recv

func Recv[T any](out *T) http.Arrow

Recv 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.

Types

type Content

type Content Header

Content defines headers for content negotiation

func (Content) Any

func (h Content) Any(cat *http.Context) error

Any matches a header value `???: *`

func (Content) ApplicationJSON added in v1.1.0

func (h Content) ApplicationJSON(cat *http.Context) error

ApplicationJSON matches header `???: application/json`

func (Content) Form

func (h Content) Form(cat *http.Context) error

Form matches Header `???: application/x-www-form-urlencoded`

func (Content) HTML

func (h Content) HTML(cat *http.Context) error

HTML matches Header `???: text/html`

func (Content) Is

func (h Content) Is(value string) http.Arrow

Is matches value of HTTP header, Use wildcard string ("*") to match any header value

func (Content) JSON

func (h Content) JSON(cat *http.Context) error

JSON matches header `???: application/json`

func (Content) Text

func (h Content) Text(cat *http.Context) error

Text matches Header `???: text/plain`

func (Content) TextHTML added in v1.1.0

func (h Content) TextHTML(cat *http.Context) error

TextHTML matches Header `???: text/html`

func (Content) TextPlain added in v1.1.0

func (h Content) TextPlain(cat *http.Context) error

TextPlain matches Header `???: text/plain`

func (Content) To added in v1.1.0

func (h Content) To(value *string) http.Arrow

String matches a header value to closed variable of string type.

type Header 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(...),
	)

func (Header) Any

func (header Header) Any(cat *http.Context) error

Any matches a header value, syntax sugar of Header(...).Is("*")

func (Header) Is

func (header Header) Is(value string) http.Arrow

Is matches value of HTTP header, Use wildcard string ("*") to match any header value

func (Header) Match

func (header Header) Match(cat *http.Context, value string) error

Match is combinator to check HTTP header value

func (Header) To added in v1.1.0

func (header Header) To(value *string) http.Arrow

To matches a header value to closed variable of string type.

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) OK

func (code StatusCode) OK(cat *http.Context) error

OK ⟼ http.StatusOK

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

func (StatusCode) UseProxy

func (code StatusCode) UseProxy(cat *http.Context) error

UseProxy ⟼ http.StatusUseProxy

Jump to

Keyboard shortcuts

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