uri

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2022 License: Apache-2.0 Imports: 6 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 Acquire

func Acquire() *url.URL

Acquire acquires new url.URL from pool.

func Clone

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

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

Call Put for performance.

func Put

func Put(u *url.URL)

Put puts url.URL to pool.

Types

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(cfg HeaderDecoderConfig) *HeaderDecoder

func (*HeaderDecoder) DecodeArray

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

func (*HeaderDecoder) DecodeFields

func (d *HeaderDecoder) DecodeFields(f func(field string, d Decoder) error) error

func (*HeaderDecoder) DecodeValue

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

type HeaderDecoderConfig

type HeaderDecoderConfig struct {
	Value   string
	Explode bool
}

type HeaderEncoder

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

func NewHeaderEncoder

func NewHeaderEncoder(cfg HeaderEncoderConfig) *HeaderEncoder

func (HeaderEncoder) EncodeArray

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

func (HeaderEncoder) EncodeField

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

func (HeaderEncoder) EncodeValue

func (s HeaderEncoder) EncodeValue(v string) error

func (*HeaderEncoder) Result

func (e *HeaderEncoder) Result() (string, bool)

type HeaderEncoderConfig

type HeaderEncoderConfig struct {
	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() string

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(cfg QueryDecoderConfig) *QueryDecoder

func (*QueryDecoder) DecodeArray

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

func (*QueryDecoder) DecodeFields

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

func (*QueryDecoder) DecodeValue

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

type QueryDecoderConfig

type QueryDecoderConfig struct {
	Param   string
	Values  []string
	Style   QueryStyle
	Explode bool
}

type QueryEncoder

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

func NewQueryEncoder

func NewQueryEncoder(cfg QueryEncoderConfig) *QueryEncoder

func (QueryEncoder) EncodeArray

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

func (QueryEncoder) EncodeField

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

func (QueryEncoder) EncodeValue

func (s QueryEncoder) EncodeValue(v string) error

func (*QueryEncoder) Result

func (e *QueryEncoder) Result() []string

type QueryEncoderConfig

type QueryEncoderConfig struct {
	Param   string
	Style   QueryStyle
	Explode 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