routes

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package routes holds what route options configure, for the SDK core.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrPrefix: an HTTP path prefix the SDK cannot announce consistently.
	ErrPrefix = errors.New("route: bad path prefix")
)

Errors.

Functions

func ChainStream

ChainStream folds interceptors into one, the first outermost; nil when there are none.

func ChainUnary

ChainUnary folds interceptors into one, the first outermost; nil when there are none.

func Prefix

func Prefix(p string) (string, error)

Prefix normalizes an HTTP path prefix for the service HTTP mux: it must start with "/", carry no method, host or wildcard, and ends with "/" ("/api" serves "/api/..." and redirects "/api").

func ServiceOf

func ServiceOf(fullMethod string) string

ServiceOf is the service of a full method ("/pkg.Svc/Method" -> "pkg.Svc").

Types

type Dispatch

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

Dispatch runs a registration's own interceptors on a gRPC server shared by several registrations: one public port is one grpc.Server, so author interceptors are keyed by the service a call's full method names.

func NewDispatch

func NewDispatch() *Dispatch

NewDispatch creates an empty dispatch.

func (*Dispatch) Add

func (d *Dispatch) Add(services []string, unary []grpc.UnaryServerInterceptor, stream []grpc.StreamServerInterceptor)

Add installs the interceptors for the named services.

func (*Dispatch) ServerOptions

func (d *Dispatch) ServerOptions() []grpc.ServerOption

ServerOptions installs the dispatch on a server.

func (*Dispatch) Stream

Stream runs the stream interceptors of the called service.

func (*Dispatch) Unary

Unary runs the unary interceptors of the called service.

type Hosts

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

Hosts serves one path prefix for several hosts, using HTTP Host matching them: an exact host, then the longest "*.suffix" wildcard, then the route without a host. A request no route matches gets 404.

func NewHosts

func NewHosts() *Hosts

NewHosts creates an empty host switch.

func (*Hosts) Add

func (s *Hosts) Add(host string, h http.Handler) bool

Add serves h for host ("" = any host); false when host is taken.

func (*Hosts) ServeHTTP

func (s *Hosts) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Managed

type Managed struct {
	Listen      string
	Host        string
	OpenAPI     []byte // HTTP
	SchemaFiles *SchemaFiles
	// gRPC and ws-proto: interceptors of this registration only.
	Unary  []grpc.UnaryServerInterceptor
	Stream []grpc.StreamServerInterceptor
	// HTTP and ws-proto: wraps this route's handler; the first is outermost.
	Middleware []func(http.Handler) http.Handler
	// gRPC: serve grpc.reflection on the route's port.
	Reflection bool
}

Managed is a route the SDK serves.

func (Managed) Wrap

func (m Managed) Wrap(h http.Handler) http.Handler

Wrap applies the middleware to h, the first one outermost.

type SchemaFiles

type SchemaFiles struct {
	Files *apifiles.Files
	Ref   *backplanev1.APISchemaBundle
	Err   error
}

SchemaFiles is a file snapshot and its manifest reference (or a declaration error).

Jump to

Keyboard shortcuts

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