httpencoding

package
v1.10.0-alpha.27 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: MIT Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package httpencoding owns named URL field serialization contracts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckNamespaces

func CheckNamespaces(loc Location, bindings []Binding) error

CheckNamespaces rejects overlapping claims between endpoint bindings. It retains every binding, including those with equal diagnostic names.

func MatchMultipart

func MatchMultipart(value BranchShape, source Serialization) error

MatchMultipart checks that authored style flags retain the existing native text/repeated-part or JSON-part codec. RFC 6570 multipart expansion is separate.

func MultipartContentType

func MultipartContentType(shape Shape, binary bool, authored string) (string, error)

MultipartContentType resolves a field's part media type and verifies that an authored override agrees with the native text, raw byte, or JSON field codec.

func Resolve

func Resolve(loc Location, name string, value BranchShape, source Serialization) (Codec, KeySet, error)

Resolve selects a codec and namespace for one named or root binding.

func ResolveUnion

func ResolveUnion(loc Location, name string, branches []BranchShape, source Serialization) ([]BranchCodec, KeySet, error)

ResolveUnion resolves every alternative under one effective serialization.

Types

type Binding

type Binding struct {
	// Name describes this binding in validation diagnostics.
	Name string
	// Keys identifies the wire namespace owned by this binding.
	Keys KeySet
}

Binding is one independently authored parameter or synthetic transport claim. Name is a diagnostic label, not its identity; equal names remain distinct.

type BranchCodec

type BranchCodec struct {
	// Codec is the alternative's resolved grammar.
	Codec Codec
	// Keys is the alternative's wire-key claim.
	Keys KeySet
	// Inner contains alternatives of a nested Union.
	Inner []BranchCodec
}

BranchCodec retains one resolved union alternative and its key ownership.

type BranchShape

type BranchShape struct {
	// Shape is the value's structural category.
	Shape Shape
	// Properties retains fixed scalar members in declaration order.
	Properties []PropertyFact
	// Keys describes a ScalarMap's dynamic key domain.
	Keys KeyDomain
	// Domain describes the scalar, sequence element or map value domain.
	Domain ValueDomain
	// Branches retains Union alternatives in declaration order.
	Branches []BranchShape
}

BranchShape describes a binding or union alternative after resolving aliases.

type Codec

type Codec struct {
	// Style identifies the grammar, including JSON content and root layouts.
	Style Style
	// Explode is effective and normalized for this value shape.
	Explode bool
	// Shape identifies the bound value's structural category.
	Shape Shape
}

Codec is the resolved wire grammar of a binding.

type KeyDomain

type KeyDomain struct {
	// Unreserved reports that every emitted key uses RFC 3986 unreserved bytes.
	Unreserved bool
}

KeyDomain retains the admitted text domain of dynamic object keys.

type KeySet

type KeySet struct {
	// Literals contains exact decoded key names.
	Literals []string
	// Prefixes contains deepObject names, each owning name[key].
	Prefixes []string
	// Residual claims every key not owned by a sibling binding.
	Residual bool
}

KeySet is the set of wire keys owned by one endpoint binding.

type Location

type Location uint8

Location distinguishes named values from root URL layouts.

const (
	// NamedQuery is an ordinary named query parameter.
	NamedQuery Location = iota
	// FormField is a named URL-encoded form property.
	FormField
	// WholeQuery is the unprefixed MapParams layout.
	WholeQuery
	// FormRoot is the unwrapped form body layout.
	FormRoot
	// Path is one whole path-segment binding.
	Path
	// Header is a request or response header binding.
	Header
	// Cookie is a request cookie binding.
	Cookie
)

type PropertyFact

type PropertyFact struct {
	// WireName is the serialized property name.
	WireName string
	// Required distinguishes required members from optional members.
	Required bool
	// Kind is the property's JSON scalar domain.
	Kind ScalarKind
	// Domain records the property's value alphabet.
	Domain ValueDomain
}

PropertyFact describes one fixed object's scalar property.

type ScalarKind

type ScalarKind uint8

ScalarKind identifies a scalar's JSON domain, independently of Go width.

const (
	// Boolean is the JSON boolean domain.
	Boolean ScalarKind = iota
	// Integer is the JSON integer domain without a carrier width.
	Integer
	// Number is the JSON number domain without a carrier width.
	Number
	// String is the JSON string domain.
	String
	// Bytes is a byte string represented as text.
	Bytes
)

type Serialization

type Serialization struct {
	// MediaType is the parameter content or form field contentType.
	MediaType string
	// Style is the authored RFC6570 serialization style.
	Style string
	// Explode is the explicitly authored explode setting.
	Explode *bool
	// AllowReserved is the explicitly authored URI escaping setting.
	AllowReserved *bool
}

Serialization describes authored OpenAPI serialization fields. Pointers preserve explicit presence, which changes form encoding semantics.

func NormalizeOpenAPIParameter

func NormalizeOpenAPIParameter(location Location, source Serialization) Serialization

NormalizeOpenAPIParameter supplies OpenAPI schema-parameter defaults while preserving content contracts and the presence of authored serialization flags.

type Shape

type Shape uint8

Shape describes the value at a URL field boundary, after alias resolution.

const (
	// Scalar is one primitive value, including bytes.
	Scalar Shape = iota
	// Sequence is an array of scalar values.
	Sequence
	// Nested contains values beyond one scalar collection level.
	Nested
	// Object is a fixed object value.
	Object
	// UnsupportedShape is a shape without a built-in URL codec.
	UnsupportedShape
	// ScalarMap is a dynamic object with scalar values.
	ScalarMap
	// Union contains alternatives resolved under one binding style.
	Union
)

type Style

type Style uint8

Style identifies a resolved parameter serialization grammar.

const (
	// Simple uses comma-delimited lists and associative values.
	Simple Style = iota
	// Matrix prefixes path values with semicolon-delimited names.
	Matrix
	// Label prefixes path values with a dot.
	Label
	// Form uses URI query/form expansion rules.
	Form
	// SpaceDelimited separates collection members with spaces.
	SpaceDelimited
	// PipeDelimited separates collection members with vertical bars.
	PipeDelimited
	// DeepObject uses bracketed property names.
	DeepObject
	// CookieStyle uses raw cookie pairs and comma-delimited collections.
	CookieStyle
	// JSON encodes one complete JSON document under a field name.
	JSON
	// Root preserves the unwrapped root layout.
	Root
)

type ValueDomain

type ValueDomain struct {
	// Unreserved reports that every emitted value uses RFC 3986 unreserved bytes.
	Unreserved bool
}

ValueDomain retains facts needed to compare cookie encodings.

Jump to

Keyboard shortcuts

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