Documentation
¶
Overview ¶
Package httpencoding owns named URL field serialization contracts.
Index ¶
- func CheckNamespaces(loc Location, bindings []Binding) error
- func Resolve(loc Location, name string, value BranchShape, source Serialization) (Codec, KeySet, error)
- type Application
- type Binding
- type BranchCodec
- type BranchShape
- type Codec
- type FieldCodec
- type KeyDomain
- type KeySet
- type Location
- type MultipartCodec
- type PartKind
- type PropertyFact
- type ScalarKind
- type Serialization
- type Shape
- type Style
- type ValueDomain
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckNamespaces ¶
CheckNamespaces rejects overlapping claims between endpoint bindings. It retains every binding, including those with equal diagnostic names.
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.
Types ¶
type Application ¶
type Application uint8
Application identifies the source value to which a content encoding applies.
const ( // Value applies the codec to the complete field value, or its style expansion. Value Application = iota // Items applies the content codec separately to each top-level array item. Items )
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 {
// Binary identifies a byte value for multipart raw-part encoding.
Binary bool
// SourceType retains the effective source JSON Schema type before normalization.
// Empty means native inference; "absent" preserves an omitted source type.
SourceType string
// Items retains the complete array item shape, including nested arrays/unions.
Items *BranchShape
// Shape is the value's structural category.
Shape Shape
// Nullable reports whether the value admits explicit JSON null.
Nullable bool
// 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 {
// Application distinguishes a whole field from one content value per array item.
Application Application
// Branches retains alternative grammars when a union has a style or item codec.
Branches []BranchCodec
// 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 FieldCodec ¶
type FieldCodec struct {
// Codec is the resolved value grammar; omitted fields have no grammar.
Codec
// Name is the effective outer form name after authored tag overrides.
Name string
// Omitted excludes this field from encoding, decoding and key claims.
Omitted bool
// Keys is the namespace claimed by this field's resolved grammar.
Keys KeySet
}
FieldCodec captures one form field's effective wire identity and grammar.
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 MultipartCodec ¶
type MultipartCodec struct {
// Keys is the complete physical namespace claimed by this field.
Keys KeySet
// StyleCodec retains explicit RFC6570 framing; nil selects content encoding.
StyleCodec *Codec
// Branches retains ordered item codecs for a source-array union.
Branches []MultipartCodec
// Application distinguishes one whole value from one part per array item.
Application Application
// ContentType is the concrete media label written on each part.
ContentType string
// Kind selects text, JSON, or raw byte encoding and decoding.
Kind PartKind
}
MultipartCodec captures the grammar and media label of one multipart field. Consumers must use Kind rather than infer the grammar from the field shape or ContentType: binary fields retain raw bytes under custom media labels.
func ResolveMultipart ¶
func ResolveMultipart(name string, value BranchShape, source Serialization) (MultipartCodec, error)
ResolveMultipart captures named multipart encoding from source type facts. Content encoding applies once per item of an explicitly array-valued property. Typeless unions retain whole-value application. Explicit serialization flags select RFC6570 framing and suppress authored contentType, as in OpenAPI 3.2. Binary values remain raw parts; their identity follows the applied value, including array items. Branches retain heterogeneous source-array codecs.
type PartKind ¶
type PartKind uint8
PartKind identifies a multipart field's concrete value representation.
const ( // TextPart encodes scalars as text and scalar lists as repeated text parts. TextPart PartKind = iota // JSONPart encodes one complete JSON document in a single part. JSONPart // BinaryPart encodes raw bytes with the authored concrete media label. BinaryPart // BranchPart selects a codec from Branches using original union membership. BranchPart )
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 authored parameter content or 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 retains authored serialization settings. 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 // AnyValue is an unconstrained JSON value, distinct from unsupported Go shapes. AnyValue )
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 // Content retains per-branch content grammars for a source-array union field. // Consumers must use Branches instead of treating this as one URI style. Content )
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.