contenttype

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// EncodingBase64 is base64 encoding for the data url
	EncodingBase64 = "base64"
	// EncodingASCII is ascii encoding for the data url
	EncodingASCII = "ascii"
)

Variables

This section is empty.

Functions

func DecodeArbitraryXML

func DecodeArbitraryXML(r io.Reader) (any, error)

DecodeArbitraryXML decodes an arbitrary XML from a reader stream.

func EncodeQueryValues added in v0.6.0

func EncodeQueryValues(qValues url.Values, allowReserved bool) string

EncodeQueryValues encode query values to string.

func EvalQueryParameterURL added in v0.6.0

func EvalQueryParameterURL(q *url.Values, name string, encObject rest.EncodingObject, keys Keys, values []string)

EvalQueryParameterURL evaluate the query parameter URL

func SetHeaderParameters added in v0.6.0

func SetHeaderParameters(header *http.Header, param *rest.RequestParameter, queryParams ParameterItems)

SetHeaderParameters set parameters to request headers

func StringifySimpleScalar

func StringifySimpleScalar(val reflect.Value, kind reflect.Kind) (string, error)

StringifySimpleScalar converts a simple scalar value to string.

func UnwrapNullableType added in v0.6.0

func UnwrapNullableType(input schema.Type) (schema.TypeEncoder, bool, error)

UnwrapNullableType unwraps the underlying type of the nullable type

Types

type DataURI

type DataURI struct {
	MediaType  string
	Parameters map[string]string
	Data       string
}

DataURI represents the Data URI scheme

func DecodeDataURI

func DecodeDataURI(input string) (*DataURI, error)

DecodeDataURI decodes data URI scheme data:[<media type>][;<key>=<value>][;<extension>],<data>

type JSONDecoder added in v0.6.0

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

JSONDecoder implements a dynamic JSON decoder from the HTTP schema.

func NewJSONDecoder added in v0.6.0

func NewJSONDecoder(httpSchema *rest.NDCHttpSchema) *JSONDecoder

NewJSONDecoder creates a new JSON encoder.

func (*JSONDecoder) Decode added in v0.6.0

func (c *JSONDecoder) Decode(r io.Reader, resultType schema.Type) (any, error)

Decode unmarshals json and evaluate the schema type.

type Key added in v0.6.0

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

Key represents a key string or index

func NewIndexKey added in v0.6.0

func NewIndexKey(index int) Key

NewIndexKey creates an index key

func NewKey added in v0.6.0

func NewKey(key string) Key

NewKey creates a string key

func (Key) Index added in v0.6.0

func (k Key) Index() *int

Index gets the integer key

func (Key) IsEmpty added in v0.6.0

func (k Key) IsEmpty() bool

IsEmpty checks if the key is empty

func (Key) Key added in v0.6.0

func (k Key) Key() string

Key gets the string key

func (Key) String added in v0.6.0

func (k Key) String() string

String implements fmt.Stringer interface

type Keys added in v0.6.0

type Keys []Key

Keys represent a key slice

func (Keys) String added in v0.6.0

func (ks Keys) String() string

String implements fmt.Stringer interface

type MultipartFormEncoder added in v0.6.0

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

MultipartFormEncoder implements a multipart/form encoder.

func NewMultipartFormEncoder added in v0.6.0

func NewMultipartFormEncoder(schema *rest.NDCHttpSchema, operation *rest.OperationInfo, arguments map[string]any) *MultipartFormEncoder

func (*MultipartFormEncoder) Encode added in v0.6.0

func (c *MultipartFormEncoder) Encode(bodyData any) (*bytes.Reader, string, error)

Encode the multipart form.

func (*MultipartFormEncoder) EncodeArbitrary added in v0.7.0

func (c *MultipartFormEncoder) EncodeArbitrary(bodyData any) (*bytes.Reader, string, error)

EncodeArbitrary encodes the unknown data to multipart/form.

type MultipartWriter

type MultipartWriter struct {
	*multipart.Writer
}

MultipartWriter extends multipart.Writer with helpers

func NewMultipartWriter

func NewMultipartWriter(w io.Writer) *MultipartWriter

NewMultipartWriter creates a MultipartWriter instance

func (*MultipartWriter) WriteDataURI

func (w *MultipartWriter) WriteDataURI(name string, value any, headers http.Header) error

WriteDataURI write a file from data URI string

func (*MultipartWriter) WriteField

func (w *MultipartWriter) WriteField(fieldName, value string, headers http.Header) error

WriteField calls CreateFormField and then writes the given value.

func (*MultipartWriter) WriteJSON

func (w *MultipartWriter) WriteJSON(fieldName string, value any, headers http.Header) error

WriteField calls CreateFormField and then writes the given value with json encoding.

type ParameterItem added in v0.6.0

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

ParameterItem represents the key-value slice pair

func NewParameterItem added in v0.6.0

func NewParameterItem(keys Keys, values []string) ParameterItem

NewParameterItem creates a parameter value pair

func (*ParameterItem) Add added in v0.6.0

func (ssp *ParameterItem) Add(key Key, value string)

func (*ParameterItem) AddKey added in v0.6.0

func (ssp *ParameterItem) AddKey(key Key)

func (*ParameterItem) AddKeys added in v0.6.0

func (ssp *ParameterItem) AddKeys(keys []Key)

func (*ParameterItem) AddValue added in v0.6.0

func (ssp *ParameterItem) AddValue(value string)

func (*ParameterItem) AddValues added in v0.6.0

func (ssp *ParameterItem) AddValues(values []string)

func (ParameterItem) Keys added in v0.6.0

func (ssp ParameterItem) Keys() Keys

Keys returns keys of the parameter item

func (*ParameterItem) PrependKey added in v0.6.0

func (ssp *ParameterItem) PrependKey(key Key)

func (*ParameterItem) PrependKeys added in v0.6.0

func (ssp *ParameterItem) PrependKeys(keys []Key)

func (*ParameterItem) PrependValue added in v0.6.0

func (ssp *ParameterItem) PrependValue(value string)

func (*ParameterItem) PrependValues added in v0.6.0

func (ssp *ParameterItem) PrependValues(values []string)

func (ParameterItem) String added in v0.6.0

func (ssp ParameterItem) String() string

String implements fmt.Stringer interface

func (ParameterItem) Values added in v0.6.0

func (ssp ParameterItem) Values() []string

type ParameterItems added in v0.6.0

type ParameterItems []ParameterItem

func (*ParameterItems) Add added in v0.6.0

func (ssp *ParameterItems) Add(keys []Key, values []string)

func (ParameterItems) Find added in v0.6.0

func (ssp ParameterItems) Find(keys []Key) *ParameterItem

func (ParameterItems) FindDefault added in v0.6.0

func (ssp ParameterItems) FindDefault() *ParameterItem

func (ParameterItems) FindIndex added in v0.6.0

func (ssp ParameterItems) FindIndex(keys []Key) int

func (ParameterItems) String added in v0.6.0

func (ssp ParameterItems) String() string

String implements fmt.Stringer interface

type URLParameterEncoder added in v0.6.0

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

URLParameterEncoder represents a URL parameter encoder.

func NewURLParameterEncoder added in v0.6.0

func NewURLParameterEncoder(schema *rest.NDCHttpSchema, contentType string) *URLParameterEncoder

NewURLParameterEncoder creates a URLParameterEncoder instance.

func (*URLParameterEncoder) Encode added in v0.6.0

func (c *URLParameterEncoder) Encode(bodyInfo *rest.ArgumentInfo, bodyData any) (io.ReadSeeker, int64, error)

func (*URLParameterEncoder) EncodeArbitrary added in v0.7.0

func (c *URLParameterEncoder) EncodeArbitrary(bodyData any) (io.ReadSeeker, int64, error)

Encode marshals the arbitrary body to xml bytes.

func (*URLParameterEncoder) EncodeParameterValues added in v0.6.0

func (c *URLParameterEncoder) EncodeParameterValues(objectField *rest.ObjectField, reflectValue reflect.Value, fieldPaths []string) (ParameterItems, error)

type XMLDecoder

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

XMLDecoder implements a dynamic XML decoder from the HTTP schema.

func NewXMLDecoder

func NewXMLDecoder(httpSchema *rest.NDCHttpSchema) *XMLDecoder

NewXMLDecoder creates a new XML encoder.

func (*XMLDecoder) Decode

func (c *XMLDecoder) Decode(r io.Reader, resultType schema.Type) (any, error)

Decode unmarshals xml bytes to a dynamic type.

type XMLEncoder

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

XMLEncoder implements a dynamic XML encoder from the HTTP schema.

func NewXMLEncoder

func NewXMLEncoder(httpSchema *rest.NDCHttpSchema) *XMLEncoder

NewXMLEncoder creates a new XML encoder.

func (*XMLEncoder) Encode

func (c *XMLEncoder) Encode(bodyInfo *rest.ArgumentInfo, bodyData any) ([]byte, error)

Encode marshals the body to xml bytes.

func (*XMLEncoder) EncodeArbitrary added in v0.7.0

func (c *XMLEncoder) EncodeArbitrary(bodyData any) ([]byte, error)

Encode marshals the arbitrary body to xml bytes.

Jump to

Keyboard shortcuts

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