zipapp

package
v1.24.5 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: 10 Imported by: 0

Documentation

Overview

Package zipapp is the single way DocDB builds and runs an HTTP router.

Every DocDB listener (Data API, MCP, debug) declares its routes on a zip.App built by New and serves it on an already-bound net.Listener with Serve. Routing errors are rendered exactly as net/http.ServeMux renders them, so routes keep the status codes and bodies they had before the router moved to zip.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BaseContext

func BaseContext(ctx context.Context) zip.Handler

BaseContext returns the middleware that makes ctx the parent of every request's context, the way http.Server.BaseContext did: a handler's context carries the listener's values and is canceled when the listener stops.

It must be the first middleware an app uses, so that everything downstream derives from it.

func New

func New(name string) *zip.App

New returns an app named name with no routes.

The app is silent: DocDB logs listener lifecycle itself via Serve, and zip's own logger would duplicate it in a different format.

func Serve

func Serve(ctx context.Context, name string, app *zip.App, lis net.Listener, l *slog.Logger)

Serve runs app on the given already-bound listener until ctx is canceled.

It exits when the handler is stopped and the listener closed. name is used for the "<name> server stopped" message.

func Text

func Text(c *zip.Ctx, code int, msg string) error

Text writes msg with the given status code exactly as http.Error does.

Types

This section is empty.

Jump to

Keyboard shortcuts

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