httpkit

package
v0.3.0-alpha.1 Latest Latest
Warning

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

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

Documentation

Overview

Package httpkit composes explicit standard-library HTTP routes without a global router or hidden component registration.

Stability: alpha. Consumers should pin an exact pre-v1 Modary version.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrContributionPanic reports a recovered contribution builder panic.
	ErrContributionPanic = errors.New("HTTP contribution builder panicked")
	// ErrPlanMismatch reports assembly against an application started from a
	// different static definition.
	ErrPlanMismatch = errors.New("HTTP plan does not match application contract")
)

Functions

func NewHandler

func NewHandler(routes ...Route) (http.Handler, error)

NewHandler validates the complete route set before returning a standard Go HTTP handler. Duplicate method and path pairs fail instead of replacing an earlier component route.

Types

type AdminDescriptor

type AdminDescriptor struct {
	ID                  string   `json:"id"`
	Label               string   `json:"label"`
	Path                string   `json:"path"`
	Icon                string   `json:"icon"`
	Order               int      `json:"order"`
	Permissions         []string `json:"permissions,omitempty"`
	RequiredPermissions []string `json:"requiredPermissions,omitempty"`
}

AdminDescriptor is the backend-owned navigation and permission metadata for one optional Admin surface. Permissions is the complete set of grants the surface may inspect, while RequiredPermissions is the subset needed to show the surface at all. Both are presentation hints only; every backend route must still authorize each request.

type Builder

type Builder func(context.Context, *appkit.Application) ([]Route, error)

Builder constructs handlers only after the bound application has started.

type Contribution

type Contribution struct {
	ID       string
	Requires []module.Capability
	Routes   []RouteSpec
	Admin    *AdminDescriptor
	Build    Builder
}

Contribution is one statically inspectable HTTP/Admin component selection. Routes and Requires are validated and copied before Build may run.

type Descriptor

type Descriptor struct {
	ID       string
	Requires []module.Capability
	Routes   []RouteSpec
	Admin    *AdminDescriptor
}

Descriptor is the callback-free snapshot returned by Plan.Contributions.

type Plan

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

Plan is an immutable, preflighted HTTP/Admin composition bound to one appkit.Contract.

func NewPlan

func NewPlan(definition appkit.Definition, options appkit.Options, contributions ...Contribution) (*Plan, error)

NewPlan validates the complete application and contribution set without invoking Module or contribution callbacks.

func (*Plan) Admin

func (plan *Plan) Admin() []AdminDescriptor

Admin returns permission-bearing Admin descriptors in stable presentation order.

func (*Plan) Contributions

func (plan *Plan) Contributions() []Descriptor

Contributions returns the complete callback-free contribution selection.

func (*Plan) Handler

func (plan *Plan) Handler(ctx context.Context, application *appkit.Application) (http.Handler, error)

Handler invokes selected builders after startup, verifies their outputs exactly match the preflighted route declarations, and composes one handler.

type Route

type Route struct {
	Method  string
	Path    string
	Handler http.Handler
}

Route is one explicitly selected HTTP method, path, and handler.

type RouteSpec

type RouteSpec struct {
	Method string `json:"method"`
	Path   string `json:"path"`
}

RouteSpec declares one route before its handler exists.

Jump to

Keyboard shortcuts

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