uri

package
v0.0.0-...-cdf09a4 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

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

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

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

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

func NewCookieDecoder

func NewCookieDecoder(req *http.Request) *CookieDecoder

func (*CookieDecoder) DecodeParam

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

func (*CookieDecoder) HasParam

type CookieEncoder

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

func NewCookieEncoder

func NewCookieEncoder(req *http.Request) *CookieEncoder

func (*CookieEncoder) EncodeParam

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

type CookieParameterDecodingConfig

type CookieParameterDecodingConfig struct {
	Name    string
	Explode bool
}

type CookieParameterEncodingConfig

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

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

func (*HeaderDecoder) HasParam

type HeaderEncoder

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

func NewHeaderEncoder

func NewHeaderEncoder(header http.Header) *HeaderEncoder

func (*HeaderEncoder) EncodeParam

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

func (*HeaderEncoder) Header

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

type HeaderParameterDecodingConfig

type HeaderParameterDecodingConfig struct {
	Name    string
	Explode bool
}

type HeaderParameterEncodingConfig

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

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

func (*QueryDecoder) HasParam

type QueryEncoder

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

func NewFormEncoder

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

func NewQueryEncoder

func NewQueryEncoder() *QueryEncoder

func (*QueryEncoder) EncodeParam

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

func (*QueryEncoder) Values

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

func (*QueryEncoder) WriteMultipart

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

type QueryParameterDecodingConfig

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

type QueryParameterEncodingConfig

type QueryParameterEncodingConfig struct {
	Name    string
	Style   QueryStyle
	Explode bool
}

type QueryParameterObjectField

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