contenttype

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2025 License: Apache-2.0 Imports: 22 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 EncodePathParameters added in v0.9.0

func EncodePathParameters(
	rawPath string,
	name string,
	queryParams ParameterItems,
	enc rest.EncodingObject,
) string

EncodePathParameters encode parameters to the request path.

func EncodeQueryValues added in v0.6.0

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

EncodeQueryValues encode query values to string.

func EvalQueryParameters added in v0.9.0

func EvalQueryParameters(
	q *url.Values,
	name string,
	queryParams ParameterItems,
	encObject rest.EncodingObject,
)

EvalQueryParameters evaluate the query parameter URL.

func SetHeaderParameters added in v0.6.0

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

SetHeaderParameters encode and 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.

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 JSONDecodeOptions added in v0.9.0

type JSONDecodeOptions struct {
	StringifyJSON bool
}

JSONDecodeOptions hold decode options for the JSONDecoder.

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, options JSONDecodeOptions) *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 JSONEncoder added in v0.9.0

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

JSONEncoder implements a dynamic JSON encode from the HTTP schema.

func NewJSONEncoder added in v0.9.0

func NewJSONEncoder(httpSchema *rest.NDCHttpSchema) *JSONEncoder

NewJSONEncoder creates a new JSON encoder.

func (*JSONEncoder) Encode added in v0.9.0

func (c *JSONEncoder) Encode(input any, resultType schema.Type) ([]byte, error)

Encode 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) Format added in v0.9.0

func (ks Keys) Format(isDeepObject bool) string

Format prints parameter keys with format.

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,
	options MultipartFormEncoderOptions,
) *MultipartFormEncoder

func (*MultipartFormEncoder) Encode added in v0.6.0

func (mfb *MultipartFormEncoder) Encode(bodyData any) ([]byte, string, error)

Encode the multipart form.

func (*MultipartFormEncoder) EncodeArbitrary added in v0.7.0

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

EncodeArbitrary encodes the unknown data to multipart/form.

type MultipartFormEncoderOptions added in v0.9.0

type MultipartFormEncoderOptions struct {
	StringifyJSON bool
}

MultipartFormEncoderOptions hold decode options for the MultipartFormEncoder.

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

WriteJSON 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,
	requestBody *rest.RequestBody,
	options URLParameterEncoderOptions,
) *URLParameterEncoder

NewURLParameterEncoder creates a URLParameterEncoder instance.

func (*URLParameterEncoder) EncodeArbitrary added in v0.7.0

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

EncodeArbitrary marshals the arbitrary body to URL query parameters.

func (*URLParameterEncoder) EncodeFormBody added in v0.9.0

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

EncodeFormBody encodes body in form data format.

func (*URLParameterEncoder) EncodeParameterValues added in v0.6.0

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

type URLParameterEncoderOptions added in v0.9.0

type URLParameterEncoderOptions struct {
	StringifyJSON bool
}

URLParameterEncoderOptions hold decode options for the URLParameterEncoder.

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)

EncodeArbitrary 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