uri

package
v0.83.0 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: Apache-2.0 Imports: 9 Imported by: 149

README

Package uri implements parameter encoding/decoding for OpenAPI subset of URI templates defined by RFC 6570.

Documentation

Overview

Package uri implements OpenAPI path/query parameter encoding.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddPathParts added in v0.60.0

func AddPathParts(u *url.URL, parts ...string)

AddPathParts adds escaped path parts to the given URL.

func Clone

func Clone(u *url.URL) *url.URL

Clone clones u and returns cloned url that you can modify.

func NormalizeEscapedPath added in v0.56.0

func NormalizeEscapedPath(s string) (string, bool)

NormalizeEscapedPath normalizes escaped path.

All percent-encoded characters are upper-cased. If s contains unnecessarily escaped characters, they are unescaped.

If s contains invalid escape sequence, it returns empty string and false.

Types

type CookieDecoder added in v0.59.0

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

func NewCookieDecoder added in v0.59.0

func NewCookieDecoder(req *http.Request) *CookieDecoder

func (*CookieDecoder) DecodeParam added in v0.59.0

func (d *CookieDecoder) DecodeParam(cfg CookieParameterDecodingConfig, f func(Decoder) error) error

func (*CookieDecoder) HasParam added in v0.59.0

type CookieEncoder added in v0.59.0

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

func NewCookieEncoder added in v0.59.0

func NewCookieEncoder(req *http.Request) *CookieEncoder

func (*CookieEncoder) EncodeParam added in v0.59.0

func (e *CookieEncoder) EncodeParam(cfg CookieParameterEncodingConfig, f func(Encoder) error) error

type CookieParameterDecodingConfig added in v0.59.0

type CookieParameterDecodingConfig struct {
	Name    string
	Explode bool
}

type CookieParameterEncodingConfig added in v0.59.0

type CookieParameterEncodingConfig struct {
	Name    string
	Explode bool
}

type Decoder

type Decoder interface {
	DecodeValue() (string, error)
	DecodeArray(f func(d Decoder) error) error
	DecodeFields(f func(field string, d Decoder) error) error
}

type Encoder

type Encoder interface {
	EncodeValue(v string) error
	EncodeArray(f func(e Encoder) error) error
	EncodeField(name string, f func(e Encoder) error) error
}

type Field

type Field struct {
	Name  string
	Value string
}

type HeaderDecoder

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

func NewHeaderDecoder

func NewHeaderDecoder(header http.Header) *HeaderDecoder

func (*HeaderDecoder) DecodeParam added in v0.33.0

func (d *HeaderDecoder) DecodeParam(cfg HeaderParameterDecodingConfig, f func(Decoder) error) error

func (*HeaderDecoder) HasParam added in v0.33.0

type HeaderEncoder

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

func NewHeaderEncoder

func NewHeaderEncoder(header http.Header) *HeaderEncoder

func (*HeaderEncoder) EncodeParam added in v0.33.0

func (e *HeaderEncoder) EncodeParam(cfg HeaderParameterEncodingConfig, f func(Encoder) error) error

func (*HeaderEncoder) Header added in v0.33.0

func (e *HeaderEncoder) Header() http.Header

type HeaderParameterDecodingConfig added in v0.33.0

type HeaderParameterDecodingConfig struct {
	Name    string
	Explode bool
}

type HeaderParameterEncodingConfig added in v0.33.0

type HeaderParameterEncodingConfig struct {
	Name    string
	Explode bool
}

type PathDecoder

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

func NewPathDecoder

func NewPathDecoder(cfg PathDecoderConfig) *PathDecoder

func (*PathDecoder) DecodeArray

func (d *PathDecoder) DecodeArray(f func(d Decoder) error) error

func (*PathDecoder) DecodeFields

func (d *PathDecoder) DecodeFields(f func(name string, d Decoder) error) error

func (*PathDecoder) DecodeValue

func (d *PathDecoder) DecodeValue() (string, error)

type PathDecoderConfig

type PathDecoderConfig struct {
	Param   string // Parameter name
	Value   string // chi.URLParam(r, "paramName")
	Style   PathStyle
	Explode bool
}

type PathEncoder

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

func NewPathEncoder

func NewPathEncoder(cfg PathEncoderConfig) *PathEncoder

func (PathEncoder) EncodeArray

func (s PathEncoder) EncodeArray(f func(Encoder) error) error

func (PathEncoder) EncodeField

func (s PathEncoder) EncodeField(field string, f func(Encoder) error) error

func (PathEncoder) EncodeValue

func (s PathEncoder) EncodeValue(v string) error

func (*PathEncoder) Result

func (e *PathEncoder) Result() (r string, _ error)

type PathEncoderConfig

type PathEncoderConfig struct {
	Param   string
	Style   PathStyle
	Explode bool
}

type PathStyle

type PathStyle string
const (
	PathStyleSimple PathStyle = "simple"
	PathStyleLabel  PathStyle = "label"
	PathStyleMatrix PathStyle = "matrix"
)

func (PathStyle) String

func (s PathStyle) String() string

type QueryDecoder

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

func NewQueryDecoder

func NewQueryDecoder(values url.Values) *QueryDecoder

func (*QueryDecoder) DecodeParam added in v0.30.2

func (d *QueryDecoder) DecodeParam(cfg QueryParameterDecodingConfig, f func(Decoder) error) error

func (*QueryDecoder) HasParam added in v0.30.2

type QueryEncoder

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

func NewFormEncoder added in v0.81.0

func NewFormEncoder(ct map[string]string) *QueryEncoder

func NewQueryEncoder

func NewQueryEncoder() *QueryEncoder

func (*QueryEncoder) EncodeParam added in v0.30.2

func (e *QueryEncoder) EncodeParam(cfg QueryParameterEncodingConfig, f func(Encoder) error) error

func (*QueryEncoder) Values added in v0.30.2

func (e *QueryEncoder) Values() url.Values

func (*QueryEncoder) WriteMultipart added in v0.34.0

func (e *QueryEncoder) WriteMultipart(w *multipart.Writer) error

type QueryParameterDecodingConfig added in v0.30.2

type QueryParameterDecodingConfig struct {
	Name    string
	Style   QueryStyle
	Explode bool
	Fields  []QueryParameterObjectField // Only for object param.
}

type QueryParameterEncodingConfig added in v0.30.2

type QueryParameterEncodingConfig struct {
	Name    string
	Style   QueryStyle
	Explode bool
}

type QueryParameterObjectField added in v0.30.2

type QueryParameterObjectField struct {
	Name     string
	Required bool
}

type QueryStyle

type QueryStyle string
const (
	QueryStyleForm           QueryStyle = "form"
	QueryStyleSpaceDelimited QueryStyle = "spaceDelimited"
	QueryStylePipeDelimited  QueryStyle = "pipeDelimited"
	QueryStyleDeepObject     QueryStyle = "deepObject"
)

Jump to

Keyboard shortcuts

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