Documentation
¶
Overview ¶
Package apipolicy implements positive API validation from pinned local artifacts. It neither selects an upstream nor authenticates a caller. Response validation can prevent delivery but cannot undo an operation already executed by an origin.
Index ¶
Constants ¶
const MaxBytes = 1 << 20
const MaxDepth = 32
const MaxNodes = 4096
Variables ¶
var ErrInvalid = errors.New("API policy validation failed")
Errors never include instance values, credentials, or schema diagnostics.
Functions ¶
Types ¶
type Bundle ¶
type Bundle struct {
// contains filtered or unexported fields
}
func Load ¶
Load confines all artifact opens (including symlink resolution) to bootstrapDir. The declaration itself is pinned by descriptorSHA256 in the WAF configuration.
func (*Bundle) GRPCMethod ¶
GRPCMethod is the call-header gate. Unknown methods require explicit POST passthrough. It runs before opening an origin stream.
func (*Bundle) Passthrough ¶
type Declaration ¶
type Declaration struct {
Version string `json:"version"`
Artifacts map[string]Artifact `json:"artifacts"`
OpenAPI string `json:"openapi,omitempty"`
Descriptors string `json:"descriptors,omitempty"`
GRPC map[string]MethodPolicy `json:"grpc,omitempty"`
Passthrough []Binding `json:"passthrough,omitempty"`
}
Declaration is the descriptorPath JSON document. Every external resource must be explicitly declared and SHA-256 pinned, including the FileDescriptorSet.
type FieldPolicy ¶
FieldPolicy validates typed protobuf values. Missing presence-aware fields are distinct from explicit default values; implicit-presence scalars use defaults. Enum names are strings; unknown enum numbers remain numbers. Bytes are base64.
type MethodPolicy ¶
type MethodPolicy struct {
Request map[string]FieldPolicy `json:"request"`
Response map[string]FieldPolicy `json:"response,omitempty"`
}
type Operation ¶
type Operation struct {
// contains filtered or unexported fields
}
Operation is an immutable route-independent validation binding. A router can resolve its own destination and use the same request/response gates.
func (*Operation) ValidateRequest ¶
func (*Operation) ValidateResponse ¶
ValidateResponse runs only when the caller explicitly enables its delivery gate. The origin has already executed; no response gate is a transaction undo.