Documentation
¶
Overview ¶
Package send defines a pure computations to compose HTTP request senders
Index ¶
- Constants
- func Params[T any](query T) http.Arrow
- func Send(data interface{}) http.Arrow
- type Authority
- type Content
- func (h Content) ApplicationJSON(cat *http.Context) error
- func (h Content) Form(cat *http.Context) error
- func (h Content) HTML(cat *http.Context) error
- func (h Content) Is(value string) http.Arrow
- func (h Content) JSON(cat *http.Context) error
- func (h Content) Text(cat *http.Context) error
- func (h Content) TextHTML(cat *http.Context) error
- func (h Content) TextPlain(cat *http.Context) error
- type Header
- type Lifecycle
- type Method
- type Segment
Constants ¶
const ( GET = Method("GET") POST = Method("POST") PUT = Method("PUT") DELETE = Method("DELETE") PATCH = Method("PATCH") )
List of supported built-in method constants
const ( Accept = Content("Accept") AcceptCharset = Header("Accept-Charset") AcceptEncoding = Header("Accept-Encoding") AcceptLanguage = Header("Accept-Language") Authorization = Header("Authorization") CacheControl = Header("Cache-Control") Connection = Lifecycle("Connection") ContentEncoding = Header("Content-Encoding") ContentLength = Header("Content-Length") ContentType = Content("Content-Type") Cookie = Header("Cookie") Date = Header("Date") Host = Header("Host") IfMatch = Header("If-Match") IfModifiedSince = Header("If-Modified-Since") IfNoneMatch = Header("If-None-Match") IfRange = Header("If-Range") IfUnmodifiedSince = Header("If-Unmodified-Since") Origin = Header("Origin") Range = Header("Range") TransferEncoding = Header("Transfer-Encoding") UserAgent = Header("User-Agent") Upgrade = Header("Upgrade") )
List of supported HTTP header constants https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#Request_fields
Variables ¶
This section is empty.
Functions ¶
func Params ¶
Params appends query params to request URL. The arrow takes a struct and converts it to map[string]string. The function fails if input is not convertable to map of strings (e.g. nested struct).
func Send ¶
Send payload to destination URL. You can also use native Go data types (e.g. maps, struct, etc) as egress payload. The library implicitly encodes input structures to binary using Content-Type as a hint. The function fails if content type is not supported by the library.
The function accept a "classical" data container such as string, []bytes or io.Reader interfaces.
Types ¶
type Authority ¶ added in v1.1.0
type Authority string
Authority is part of URL, use the type to prevent escaping
type Content ¶
type Content Header
Content defines headers for content negotiation
func (Content) ApplicationJSON ¶ added in v1.1.0
ApplicationJSON defines header `???: application/json`
type Header ¶
type Header string
Header defines HTTP headers to the request, use combinator to define multiple header values.
http.Do(
ø.Header("User-Agent").Is("gurl"),
ø.Header("Content-Type").Is(content),
)
type Lifecycle ¶
type Lifecycle Header
Lifecycle defines headers for connection management