httpbinding

package
v1.22.1 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2024 License: Apache-2.0 Imports: 9 Imported by: 837

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EscapePath

func EscapePath(path string, encodeSep bool) string

EscapePath escapes part of a URL path in Amazon style.

func SplitURI

func SplitURI(uri string) (path, query string)

SplitURI parses a Smithy HTTP binding trait URI

Types

type Encoder

type Encoder struct {
	// contains filtered or unexported fields
}

An Encoder provides encoding of REST URI path, query, and header components of an HTTP request. Can also encode a stream as the payload.

Does not support SetFields.

func NewEncoder

func NewEncoder(path, query string, headers http.Header) (*Encoder, error)

NewEncoder creates a new encoder from the passed in request. It assumes that raw path contains no valuable information at this point, so it passes in path as path and raw path for subsequent trans

func NewEncoderWithRawPath added in v1.14.0

func NewEncoderWithRawPath(path, rawPath, query string, headers http.Header) (*Encoder, error)

NewHTTPBindingEncoder creates a new encoder from the passed in request. All query and header values will be added on top of the request's existing values. Overwriting duplicate values.

func (*Encoder) AddHeader

func (e *Encoder) AddHeader(key string) HeaderValue

AddHeader returns a HeaderValue for appending to the given header name

func (*Encoder) AddQuery

func (e *Encoder) AddQuery(key string) QueryValue

AddQuery returns a QueryValue used for appending the given query key

func (*Encoder) Encode

func (e *Encoder) Encode(req *http.Request) (*http.Request, error)

Encode returns a REST protocol encoder for encoding HTTP bindings.

Due net/http requiring `Content-Length` to be specified on the http.Request#ContentLength directly. Encode will look for whether the header is present, and if so will remove it and set the respective value on http.Request.

Returns any error occurring during encoding.

func (Encoder) HasHeader

func (e Encoder) HasHeader(key string) bool

HasHeader returns if a header with the key specified exists with one or more value.

func (*Encoder) HasQuery added in v1.4.0

func (e *Encoder) HasQuery(key string) bool

HasQuery returns if a query with the key specified exists with one or more values.

func (*Encoder) Headers

func (e *Encoder) Headers(prefix string) Headers

Headers returns a Header used for encoding headers with the given prefix

func (*Encoder) SetHeader

func (e *Encoder) SetHeader(key string) HeaderValue

SetHeader returns a HeaderValue for setting the given header name

func (*Encoder) SetQuery

func (e *Encoder) SetQuery(key string) QueryValue

SetQuery returns a QueryValue used for setting the given query key

func (*Encoder) SetURI

func (e *Encoder) SetURI(key string) URIValue

SetURI returns a URIValue used for setting the given path key

type HeaderValue

type HeaderValue struct {
	// contains filtered or unexported fields
}

HeaderValue is used to encode values to an HTTP header

func (HeaderValue) BigDecimal

func (h HeaderValue) BigDecimal(v *big.Float)

BigDecimal encodes the value v as a query string value

func (HeaderValue) BigInteger

func (h HeaderValue) BigInteger(v *big.Int)

BigInteger encodes the value v as a query string value

func (HeaderValue) Blob

func (h HeaderValue) Blob(v []byte)

Blob encodes the value v as a base64 header string value

func (HeaderValue) Boolean

func (h HeaderValue) Boolean(v bool)

Boolean encodes the value v as a query string value

func (HeaderValue) Byte

func (h HeaderValue) Byte(v int8)

Byte encodes the value v as a query string value

func (HeaderValue) Double

func (h HeaderValue) Double(v float64)

Double encodes the value v as a query string value

func (HeaderValue) Float

func (h HeaderValue) Float(v float32)

Float encodes the value v as a query string value

func (HeaderValue) Integer

func (h HeaderValue) Integer(v int32)

Integer encodes the value v as the header string value

func (HeaderValue) Long

func (h HeaderValue) Long(v int64)

Long encodes the value v as the header string value

func (HeaderValue) Short

func (h HeaderValue) Short(v int16)

Short encodes the value v as a query string value

func (HeaderValue) String

func (h HeaderValue) String(v string)

String encodes the value v as the header string value

type Headers

type Headers struct {
	// contains filtered or unexported fields
}

Headers is used to encode header keys using a provided prefix

func (Headers) AddHeader

func (h Headers) AddHeader(key string) HeaderValue

AddHeader returns a HeaderValue used to append values to prefix+key

func (Headers) SetHeader

func (h Headers) SetHeader(key string) HeaderValue

SetHeader returns a HeaderValue used to set the value of prefix+key

type QueryValue

type QueryValue struct {
	// contains filtered or unexported fields
}

QueryValue is used to encode query key values

func NewQueryValue

func NewQueryValue(query url.Values, key string, append bool) QueryValue

NewQueryValue creates a new QueryValue which enables encoding a query value into the given url.Values.

func (QueryValue) BigDecimal

func (qv QueryValue) BigDecimal(v *big.Float)

BigDecimal encodes v as a query string value

func (QueryValue) BigInteger

func (qv QueryValue) BigInteger(v *big.Int)

BigInteger encodes v as a query string value

func (QueryValue) Blob

func (qv QueryValue) Blob(v []byte)

Blob encodes v as a base64 query string value

func (QueryValue) Boolean

func (qv QueryValue) Boolean(v bool)

Boolean encodes v as a query string value

func (QueryValue) Byte

func (qv QueryValue) Byte(v int8)

Byte encodes v as a query string value

func (QueryValue) Double

func (qv QueryValue) Double(v float64)

Double encodes v as a query string value

func (QueryValue) Float

func (qv QueryValue) Float(v float32)

Float encodes v as a query string value

func (QueryValue) Integer

func (qv QueryValue) Integer(v int32)

Integer encodes v as a query string value

func (QueryValue) Long

func (qv QueryValue) Long(v int64)

Long encodes v as a query string value

func (QueryValue) Short

func (qv QueryValue) Short(v int16)

Short encodes v as a query string value

func (QueryValue) String

func (qv QueryValue) String(v string)

String encodes v as a query string value

type URIValue

type URIValue struct {
	// contains filtered or unexported fields
}

URIValue is used to encode named URI parameters

func (URIValue) BigDecimal

func (u URIValue) BigDecimal(v *big.Float) error

BigDecimal encodes v as a query string value

func (URIValue) BigInteger

func (u URIValue) BigInteger(v *big.Int) error

BigInteger encodes v as a query string value

func (URIValue) Boolean

func (u URIValue) Boolean(v bool) error

Boolean encodes v as a URI string value

func (URIValue) Byte

func (u URIValue) Byte(v int8) error

Byte encodes v as a URI string value

func (URIValue) Double

func (u URIValue) Double(v float64) error

Double encodes v as a query string value

func (URIValue) Float

func (u URIValue) Float(v float32) error

Float encodes v as a query string value

func (URIValue) Integer

func (u URIValue) Integer(v int32) error

Integer encodes v as a URI string value

func (URIValue) Long

func (u URIValue) Long(v int64) error

Long encodes v as a URI string value

func (URIValue) Short

func (u URIValue) Short(v int16) error

Short encodes v as a URI string value

func (URIValue) String

func (u URIValue) String(v string) error

String encodes v as a URI string value

Jump to

Keyboard shortcuts

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