Documentation
¶
Overview ¶
Package httpmodel owns the language-neutral identity and compatibility contract for statically observed HTTP methods and routes.
Index ¶
- Constants
- func BestCandidateIndexes(method string, request Route, candidates []EndpointCandidate) []int
- func CandidateCompatible(method string, request Route, candidate EndpointCandidate) bool
- func NormalizeMethod(value string) (string, error)
- func PreserveMethod(value string) (string, error)
- func WithDestinationEvidence(properties map[string]string, resolution DestinationResolution, ...) map[string]string
- type AuthorityState
- type CandidateCatalog
- type DestinationContract
- type DestinationEvidence
- type DestinationResolution
- type EndpointCandidate
- type MatchRank
- type Route
Constants ¶
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 ¶
NormalizeMethod trims, validates, and canonicalizes an HTTP method token.
func PreserveMethod ¶
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 ¶
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.
func Compatibility ¶
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 ¶
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 ¶
ParseRoute parses an absolute path or URL without decoding escaped path separators. It rejects relative, malformed, and structurally unsafe input.