send

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2021 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            = 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

func Params(query interface{}) 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 Content

type Content Header

Content defines headers for content negotiation

func (Content) Form

func (h Content) Form(cat *gurl.IOCat) *gurl.IOCat

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

func (Content) HTML

func (h Content) HTML(cat *gurl.IOCat) *gurl.IOCat

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

func (Content) Is

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

Is sets a literval value of HTTP header

func (Content) JSON

func (h Content) JSON(cat *gurl.IOCat) *gurl.IOCat

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

func (Content) Text

func (h Content) Text(cat *gurl.IOCat) *gurl.IOCat

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

func (Content) Val

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

Val sets a value of HTTP header from variable

type Header string

Header defines HTTP headers to the request, use combinator to define multiple header values.

  http.Join(
		ø.Header("Accept").Is(...),
		ø.Header("Content-Type").Is(...),
	)

func (Header) Is

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

Is sets a literval value of HTTP header

func (Header) Set

func (header Header) Set(cat *gurl.IOCat, value string) *gurl.IOCat

Set is combinator to define HTTP header into request

func (Header) Val

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

Val sets a value of HTTP header from variable

type Lifecycle

type Lifecycle Header

Lifecycle defines headers for connection management

func (Lifecycle) Close

func (h Lifecycle) Close(cat *gurl.IOCat) *gurl.IOCat

Close defines header `???: close`

func (Lifecycle) Is

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

Is sets a literval value of HTTP header

func (Lifecycle) KeepAlive

func (h Lifecycle) KeepAlive(cat *gurl.IOCat) *gurl.IOCat

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

func (Lifecycle) Val

func (h Lifecycle) Val(value *string) http.Arrow

Val sets a value of HTTP header from variable

type Method

type Method string

Method is base type for HTTP methods

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.

Jump to

Keyboard shortcuts

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