Documentation
¶
Overview ¶
Package web owns target-independent compilation support for trb/web.
Index ¶
- Constants
- func Analyze(sources []Source, resolutions map[string]resolver.Result, sourceRoot string) (*Manifest, []Issue)
- func BuildEndpointCatalog(input packageextension.ProjectDeclarationInput, routes []Route) (EndpointCatalog, []EndpointContractIssue, error)
- func Declarations(input packageextension.ProjectDeclarationInput) (*declaration.Catalog, error)
- func Discover(sources []Source, sourceRoot string) ([]Route, []Issue)
- func ValidateEndpointCatalog(catalog EndpointCatalog) error
- type EndpointCatalog
- type EndpointContract
- type EndpointContractIssue
- type EndpointResponse
- type Issue
- type Manifest
- type Middleware
- type Route
- type Source
Constants ¶
const ( PackageName = "trb/web" ModulePath = "trb/web/index" ProjectProvider = "trb.web.routes" )
const EndpointCatalogProtocolVersion = 1
const MaxBodyBytes = 1 << 20
MaxBodyBytes is the portable request body limit enforced by every adapter.
Variables ¶
This section is empty.
Functions ¶
func BuildEndpointCatalog ¶ added in v0.3.34
func BuildEndpointCatalog(input packageextension.ProjectDeclarationInput, routes []Route) (EndpointCatalog, []EndpointContractIssue, error)
BuildEndpointCatalog validates authored endpoint declarations and binds them to the routes discovered from the same project. Routes without a contract remain valid; a contract must map to exactly one local file-route handler.
func Declarations ¶ added in v0.3.34
func Declarations(input packageextension.ProjectDeclarationInput) (*declaration.Catalog, error)
Declarations returns the generic declaration capabilities required by endpoint contract classes. Calls remain ordinary, type-checked trb/web functions; only exact Endpoint subclasses discovered from this data-only project snapshot may treat them as non-runtime declarations.
func ValidateEndpointCatalog ¶ added in v0.3.34
func ValidateEndpointCatalog(catalog EndpointCatalog) error
Types ¶
type EndpointCatalog ¶ added in v0.3.34
type EndpointCatalog struct {
ProtocolVersion int `json:"protocolVersion"`
Package string `json:"package"`
Endpoints []EndpointContract `json:"endpoints,omitempty"`
}
EndpointCatalog is the versioned, target-independent contract exposed by trb/web. It binds authored endpoint declarations to file-based routes while retaining portable TypeRB type uses for downstream tools such as OpenAPI generators. It never contains parser nodes, checked method bodies, or backend-specific data.
type EndpointContract ¶ added in v0.3.34
type EndpointContract struct {
Name string `json:"name"`
ModulePath string `json:"modulePath"`
Handler string `json:"handler"`
Method string `json:"method"`
Path string `json:"path"`
Input *packageextension.ProjectTypeUse `json:"input,omitempty"`
Responses []EndpointResponse `json:"responses"`
Span packageextension.SourceSpan `json:"span"`
}
type EndpointContractIssue ¶ added in v0.3.34
type EndpointContractIssue struct {
ModulePath string
Message string
Span packageextension.SourceSpan
}
type EndpointResponse ¶ added in v0.3.34
type EndpointResponse struct {
Status int `json:"status"`
Type packageextension.ProjectTypeUse `json:"type"`
Span packageextension.SourceSpan `json:"span"`
}
type Manifest ¶
type Manifest struct {
Routes []Route
Middlewares []Middleware
EndpointCatalog EndpointCatalog
}
func ManifestFrom ¶
func (*Manifest) ExtensionName ¶
type Middleware ¶
type Middleware struct {
Filename string
Directory string
ModulePath string
Handler string
TargetHandler string
Span token.Span
}
func NestedMiddlewares ¶ added in v0.2.3
func NestedMiddlewares(middlewares []Middleware) []Middleware
NestedMiddlewares returns middleware that is scoped below the route root. Root middleware is applied once around the complete dispatcher instead.
func RootMiddlewares ¶ added in v0.2.3
func RootMiddlewares(middlewares []Middleware) []Middleware
RootMiddlewares returns the middleware that applies to every request, including responses produced before or after route matching.
type Route ¶
type Route struct {
Filename string
Directory string
Method string
Path string
ModulePath string
Handler string
TargetHandler string
PathParameters []string
Middlewares []Middleware
Span token.Span
}
func UniquePathRoutes ¶
UniquePathRoutes returns the first route for each path in manifest order. Handlers in one route file share the same path parameters and middleware.