Documentation ¶
Overview ¶
Package send defines a pure computations to compose HTTP request senders
Index ¶
- Constants
- func Header[T http.ReadableHeaderValues](header string, value T) http.Arrow
- func Method(verb string) http.Arrow
- func Param[T interface{ ... }](key string, val T) http.Arrow
- func Params[T any](query T) http.Arrow
- func Send(data any) http.Arrow
- func URI(url string, args ...any) http.Arrow
- type Authority
- type HeaderEnumConnection
- type HeaderEnumContent
- func (h HeaderEnumContent) ApplicationJSON(cat *http.Context) error
- func (h HeaderEnumContent) Form(cat *http.Context) error
- func (h HeaderEnumContent) HTML(cat *http.Context) error
- func (h HeaderEnumContent) JSON(cat *http.Context) error
- func (h HeaderEnumContent) Set(value string) http.Arrow
- func (h HeaderEnumContent) Text(cat *http.Context) error
- func (h HeaderEnumContent) TextHTML(cat *http.Context) error
- func (h HeaderEnumContent) TextPlain(cat *http.Context) error
- type HeaderEnumContentLength
- type HeaderEnumTransferEncoding
- type HeaderOf
- type Path
Constants ¶
const ( Accept = HeaderEnumContent("Accept") AcceptCharset = HeaderOf[string]("Accept-Charset") AcceptEncoding = HeaderOf[string]("Accept-Encoding") AcceptLanguage = HeaderOf[string]("Accept-Language") Authorization = HeaderOf[string]("Authorization") CacheControl = HeaderOf[string]("Cache-Control") Connection = HeaderEnumConnection("Connection") ContentEncoding = HeaderOf[string]("Content-Encoding") ContentLength = HeaderEnumContentLength("Content-Length") ContentType = HeaderEnumContent("Content-Type") Cookie = HeaderOf[string]("Cookie") Date = HeaderOf[time.Time]("Date") From = HeaderOf[string]("From") Host = HeaderOf[string]("Host") IfMatch = HeaderOf[string]("If-Match") IfModifiedSince = HeaderOf[time.Time]("If-Modified-Since") IfNoneMatch = HeaderOf[string]("If-None-Match") IfRange = HeaderOf[string]("If-Range") IfUnmodifiedSince = HeaderOf[time.Time]("If-Unmodified-Since") Origin = HeaderOf[string]("Origin") Range = HeaderOf[string]("Range") Referer = HeaderOf[string]("Referer") TransferEncoding = HeaderEnumTransferEncoding("Transfer-Encoding") UserAgent = HeaderOf[string]("User-Agent") Upgrade = HeaderOf[string]("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 Header ¶
func Header[T http.ReadableHeaderValues](header string, value T) http.Arrow
Header defines HTTP headers to the request
ø.Header("User-Agent", "gurl"),
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. contains 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 HeaderEnumConnection ¶
type HeaderEnumConnection string
Type of HTTP Header, Connection enumeration
const Connection = HeaderEnumConnection("Connection") ø.Connection.KeepAlive
func (HeaderEnumConnection) Close ¶
func (h HeaderEnumConnection) Close(cat *http.Context) error
Close defines header `???: close`
type HeaderEnumContent ¶
type HeaderEnumContent string
Type of HTTP Header, Content-Type enumeration
const ContentType = HeaderEnumContent("Content-Type") ø.ContentType.JSON
func (HeaderEnumContent) ApplicationJSON ¶
func (h HeaderEnumContent) ApplicationJSON(cat *http.Context) error
ApplicationJSON defines header `???: application/json`
func (HeaderEnumContent) Form ¶
func (h HeaderEnumContent) Form(cat *http.Context) error
Form defined Header `???: application/x-www-form-urlencoded`
func (HeaderEnumContent) HTML ¶
func (h HeaderEnumContent) HTML(cat *http.Context) error
HTML defined Header `???: text/html`
func (HeaderEnumContent) JSON ¶
func (h HeaderEnumContent) JSON(cat *http.Context) error
JSON defines header `???: application/json`
func (HeaderEnumContent) Set ¶
func (h HeaderEnumContent) Set(value string) http.Arrow
Sets value of HTTP header
func (HeaderEnumContent) Text ¶
func (h HeaderEnumContent) Text(cat *http.Context) error
Text defined Header `???: text/plain`
type HeaderEnumContentLength ¶
type HeaderEnumContentLength string
Header Content-Length
const ContentLength = HeaderEnumContentLength("Content-Length") ø.ContentLength.Set(1024)
type HeaderEnumTransferEncoding ¶
type HeaderEnumTransferEncoding string
Type of HTTP Header, Transfer-Encoding enumeration
const TransferEncoding = HeaderEnumTransferEncoding("Transfer-Encoding") ø.TransferEncoding.Chunked
func (HeaderEnumTransferEncoding) Chunked ¶
func (h HeaderEnumTransferEncoding) Chunked(cat *http.Context) error
Chunked defines header `Transfer-Encoding: chunked`
type HeaderOf ¶
type HeaderOf[T http.ReadableHeaderValues] string
Type of HTTP Header
const Host = HeaderOf[string]("Host") ø.Host.Set("example.com")