handler

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HeaderContentID = "X-Content-Id"
	HeaderMimeType  = "X-Mime-Type"
	HeaderErrorCode = "X-Error-Code"
)

Variables

This section is empty.

Functions

func Watch

func Watch(h *Handler, events <-chan gateway.Event)

Watch ranges over gateway events, maintains the full spec collection, and calls Apply on each change. It returns when the events channel is closed. Run it in a goroutine.

Types

type Handler

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

Handler routes HTTP requests to registered frontend services based on mime-type resolution.

func New

func New(l *zap.Logger, resolver Resolver) *Handler

New creates a Handler backed by the given Resolver.

func (*Handler) Apply

func (h *Handler) Apply(specs []gateway.Spec)

Apply rebuilds routing state from the given specs atomically.

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Resolver

type Resolver interface {
	Resolve(r *http.Request) (mimeType, contentID string, err error)
}

Resolver resolves an incoming request to a mime type and content ID. Return empty mimeType (with no error) when the content does not exist or is not accessible.

Jump to

Keyboard shortcuts

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