send

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: 9 Imported by: 1

Documentation

Overview

Package send defines a pure computations to compose HTTP request senders

Index

Constants

View Source
const (
	GET    = Method("GET")
	POST   = Method("POST")
	PUT    = Method("PUT")
	DELETE = Method("DELETE")
	PATCH  = Method("PATCH")
)

List of supported built-in method constants

View Source
const (
	Accept            = HeaderContent("Accept")
	AcceptCharset     = Header("Accept-Charset")
	AcceptEncoding    = Header("Accept-Encoding")
	AcceptLanguage    = Header("Accept-Language")
	Authorization     = Header("Authorization")
	CacheControl      = Header("Cache-Control")
	Connection        = HeaderConnection("Connection")
	ContentEncoding   = Header("Content-Encoding")
	ContentLength     = HeaderContentLength("Content-Length")
	ContentType       = HeaderContent("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  = HeaderTransferEncoding("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

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. nested struct).

func Send

func Send(data interface{}) 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.

Types

type Authority added in v1.1.0

type Authority string

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

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

func (Header) Is

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

Is sets value of HTTP header

type HeaderConnection added in v1.3.0

type HeaderConnection Header

Lifecycle defines headers for connection management

func (HeaderConnection) Close added in v1.3.0

func (h HeaderConnection) Close(cat *http.Context) error

Close defines header `???: close`

func (HeaderConnection) KeepAlive added in v1.3.0

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

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

type HeaderContent added in v1.3.0

type HeaderContent Header

Content defines headers for content negotiation

func (HeaderContent) ApplicationJSON added in v1.3.0

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

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

func (HeaderContent) Form added in v1.3.0

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

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

func (HeaderContent) HTML added in v1.3.0

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

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

func (HeaderContent) Is added in v1.3.0

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

Is sets a literval value of HTTP header

func (HeaderContent) JSON added in v1.3.0

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

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

func (HeaderContent) Text added in v1.3.0

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

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

func (HeaderContent) TextHTML added in v1.3.0

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

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

func (HeaderContent) TextPlain added in v1.3.0

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

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

type HeaderContentLength added in v1.3.0

type HeaderContentLength Header

Header Content-Length

func (HeaderContentLength) Is added in v1.3.0

func (h HeaderContentLength) Is(value int64) http.Arrow

Is sets a literval value of HTTP header

type HeaderTransferEncoding added in v1.3.0

type HeaderTransferEncoding Header

Header TransferEncoding

func (HeaderTransferEncoding) Chunked added in v1.3.0

func (h HeaderTransferEncoding) Chunked(cat *http.Context) error

Chunked defines header `Transfer-Encoding: chunked`

func (HeaderTransferEncoding) Identity added in v1.3.0

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

Identity defines header `Transfer-Encoding: identity`

func (HeaderTransferEncoding) Is added in v1.3.0

Is sets a literval value of HTTP header

type Method

type Method string

Method is base type for HTTP methods

func (Method) URI added in v1.2.0

func (method Method) URI(addr string) http.Arrow

URL defines a mandatory parameters to the request such as HTTP method and destination URI

func (Method) URL

func (method Method) URL(uri string, args ...interface{}) http.Arrow

URL defines a mandatory parameters to the request such as HTTP method and destination URL, use Params arrow if you need to supply URL query params.

type Segment added in v1.1.0

type Segment string

Segment 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