web

package
v0.3.22 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package web owns target-independent compilation support for trb/web.

Index

Constants

View Source
const (
	ModulePath      = "trb/web/index"
	ProjectProvider = "trb.web.routes"
)
View Source
const MaxBodyBytes = 1 << 20

MaxBodyBytes is the portable request body limit enforced by every adapter.

Variables

This section is empty.

Functions

func Analyze

func Analyze(sources []Source, resolutions map[string]resolver.Result, sourceRoot string) (*Manifest, []Issue)

func Discover

func Discover(sources []Source, sourceRoot string) ([]Route, []Issue)

Types

type Issue

type Issue struct {
	Filename string
	Message  string
	Span     token.Span
}

type Manifest

type Manifest struct {
	Routes      []Route
	Middlewares []Middleware
}

func ManifestFrom

func ManifestFrom(extensions []ir.Extension) *Manifest

func (*Manifest) ExtensionName

func (*Manifest) ExtensionName() string

func (*Manifest) MethodTargets

func (m *Manifest) MethodTargets() map[string]map[string]string

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

func UniquePathRoutes(routes []Route) []Route

UniquePathRoutes returns the first route for each path in manifest order. Handlers in one route file share the same path parameters and middleware.

type Source

type Source struct {
	Filename   string
	ModulePath string
	Program    *ast.Program
}

Jump to

Keyboard shortcuts

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