Help us shape the future of Go! Take the 2026 Go Developer Survey

httpmodel

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package httpmodel owns the language-neutral identity and compatibility contract for statically observed HTTP methods and routes.

Index

Constants

View Source
const (
	PropertyAuthority             = "http_authority"
	PropertyAuthorityUnknown      = "http_authority_unknown"
	PropertyDestinationResolution = "http_destination_resolution"
	PropertyDestinationEvidence   = "http_destination_evidence"
)

Request destination properties form the persisted contract between reconciliation, federation, and topology. Extractor authority properties are source evidence; destination properties are derived evidence and must agree with both the authority state and the edge target.

Variables

This section is empty.

Functions

func BestCandidateIndexes

func BestCandidateIndexes(method string, request Route, candidates []EndpointCandidate) []int

BestCandidateIndexes applies method compatibility and the strongest shared route rank, preserving input order for deterministic caller presentation.

func CandidateCompatible

func CandidateCompatible(method string, request Route, candidate EndpointCandidate) bool

CandidateCompatible reports whether one declaration is eligible for a request. ANY is the explicit method-less declaration identity; qualified declarations never prove an unqualified local destination.

func NormalizeMethod

func NormalizeMethod(value string) (string, error)

NormalizeMethod trims, validates, and canonicalizes an HTTP method token.

func PreserveMethod

func PreserveMethod(value string) (string, error)

PreserveMethod validates an HTTP method token without changing its case-sensitive identity. ServeMux declarations use this because Go matches method tokens exactly.

func WithDestinationEvidence

func WithDestinationEvidence(properties map[string]string, resolution DestinationResolution,
	evidence DestinationEvidence,
) map[string]string

WithDestinationEvidence copies properties and replaces only the derived destination evidence. Extractor evidence is never mutated in place.

Types

type AuthorityState

type AuthorityState string
const (
	AuthorityLocal    AuthorityState = "local"
	AuthorityExternal AuthorityState = "external"
	AuthorityUnknown  AuthorityState = "unknown"
)

type CandidateCatalog

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

CandidateCatalog indexes a stable endpoint snapshot by method so repeated requests do not rescan declarations which cannot possibly match. Returned indexes always refer to the original candidate slice.

func NewCandidateCatalog

func NewCandidateCatalog(candidates []EndpointCandidate) CandidateCatalog

NewCandidateCatalog builds a reusable method index without changing input order, which keeps ambiguity presentation deterministic for callers.

func (CandidateCatalog) BestCandidateIndexes

func (catalog CandidateCatalog) BestCandidateIndexes(method string, request Route) []int

BestCandidateIndexes applies route compatibility only to declarations with the requested method and returns indexes into the original candidate slice.

type DestinationContract

type DestinationContract struct {
	Authority  AuthorityState
	Resolution DestinationResolution
	Evidence   DestinationEvidence
}

DestinationContract is the canonical interpretation of extractor authority evidence and reconciler destination evidence for one request fact.

func ParseDestinationContract

func ParseDestinationContract(properties map[string]string, route Route) (DestinationContract, error)

ParseDestinationContract validates source and derived request properties. The parsed route is included because older extractors encoded an absolute authority only in the symbolic target rather than in edge properties.

func (DestinationContract) ValidateTarget

func (contract DestinationContract) ValidateTarget(external bool) error

ValidateTarget fails closed when persisted destination evidence disagrees with the actual edge target. Legacy external edges remain explicitly unresolved; a legacy local edge is unsafe because it lacks resolution proof.

type DestinationEvidence

type DestinationEvidence string
const (
	EvidenceRoute             DestinationEvidence = "route"
	EvidenceExactTarget       DestinationEvidence = "exact_target"
	EvidenceFederated         DestinationEvidence = "federated"
	EvidenceUnknownAuthority  DestinationEvidence = "unknown_authority"
	EvidenceExplicitAuthority DestinationEvidence = "explicit_authority"
)

type DestinationResolution

type DestinationResolution string
const (
	DestinationResolved   DestinationResolution = "resolved"
	DestinationAmbiguous  DestinationResolution = "ambiguous"
	DestinationUnresolved DestinationResolution = "unresolved"
	DestinationExternal   DestinationResolution = "external"
)

type EndpointCandidate

type EndpointCandidate struct {
	Method    string
	Authority string
	Route     Route
}

EndpointCandidate contains only the language-neutral declaration evidence needed to rank a request against endpoint declarations.

type MatchRank

type MatchRank uint8

MatchRank orders compatible declarations from strongest to weakest. RankNone is not compatible; lower non-zero values are stronger matches.

const (
	RankNone MatchRank = iota
	RankExact
	RankTemplate
	RankCatchAll
)

func Compatibility

func Compatibility(declaration, request Route) MatchRank

Compatibility reports whether request evidence can be proven to satisfy a declaration. The declaration is directional: an unknown request value never proves a literal or regex-constrained declaration.

type Route

type Route struct {
	Raw       string
	Path      string
	Canonical string
	Query     string
	Fragment  string
	Scheme    string
	Authority string
	// contains filtered or unexported fields
}

Route separates source evidence from the canonical path identity used for matching. Canonical never contains a query or fragment, and parameter names are replaced without erasing regex constraints or catchall semantics.

func Join

func Join(prefixValue, leafValue string) (Route, error)

Join composes a router prefix and leaf through the same parser used for standalone identities. Query and fragment evidence belongs to the leaf.

func ParseRoute

func ParseRoute(value string) (Route, error)

ParseRoute parses an absolute path or URL without decoding escaped path separators. It rejects relative, malformed, and structurally unsafe input.

Jump to

Keyboard shortcuts

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