send

package
v2.9.0 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: MIT Imports: 11 Imported by: 6

Documentation

Overview

Package send defines a pure computations to compose HTTP request senders

Index

Constants

View Source
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[T http.ReadableHeaderValues](header string, value T) http.Arrow

Header defines HTTP headers to the request

ø.Header("User-Agent", "gurl"),

func Method

func Method(verb string) http.Arrow

Method defines HTTP Method/Verb to the request

func Param

func Param[T interface{ string | int }](key string, val T) http.Arrow

Param appends query params to request URL.

func Params

func Params[T any](query T) http.Arrow

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

func Send(data any) http.Arrow

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.

func URI

func URI(url string, args ...any) http.Arrow

URI defines destination URI use Params arrow if you need to supply URL query params.

Types

type Authority

type Authority string

Authority is part of URL, use the type to prevent escaping

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`

func (HeaderEnumConnection) KeepAlive

func (h HeaderEnumConnection) KeepAlive(cat *http.Context) error

KeepAlive defines header `???: keep-alive`

func (HeaderEnumConnection) Set

func (h HeaderEnumConnection) Set(value string) http.Arrow

Sets 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) 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`

func (HeaderEnumContent) TextHTML

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

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

func (HeaderEnumContent) TextPlain

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

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

type HeaderEnumContentLength

type HeaderEnumContentLength string

Header Content-Length

const ContentLength = HeaderEnumContentLength("Content-Length")
ø.ContentLength.Set(1024)

func (HeaderEnumContentLength) Set

func (h HeaderEnumContentLength) Set(value int64) http.Arrow

Is sets a literal value of HTTP header

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`

func (HeaderEnumTransferEncoding) Identity

func (h HeaderEnumTransferEncoding) Identity(cat *http.Context) error

Identity defines header `Transfer-Encoding: identity`

func (HeaderEnumTransferEncoding) Set

Sets value of HTTP header

type HeaderOf

type HeaderOf[T http.ReadableHeaderValues] string

Type of HTTP Header

const Host = HeaderOf[string]("Host")
ø.Host.Set("example.com")

func (HeaderOf[T]) Set

func (h HeaderOf[T]) Set(value T) http.Arrow

Sets value of HTTP header

type Path

type Path string

Path is part of URL, use the type to prevent path escaping

Jump to

Keyboard shortcuts

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