httpapi

package
v0.70.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 26 Imported by: 0

Documentation

Overview

Package httpapi is the drive server's HTTP adapter.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Authenticate

func Authenticate(tokens *core.Tokens, sessions *core.Sessions, cookieName string) errchain.Middleware

Authenticate turns an "Authorization: Bearer hds_..." header, or else the session cookie, into a Principal in the request context. A request that sends a bearer header is judged on it alone, so a stale cookie cannot override a token.

func New

func New(log zerolog.Logger, info buildinfo.Info, svc Services) http.Handler

New returns the server's handler. /healthz is quiet in the request log unless it fails, so a probe loop does not flood it.

func Require

func Require(scope core.Scope) errchain.Middleware

Require rejects a request whose principal lacks scope. It runs after Authenticate.

func RequireSession

func RequireSession() errchain.Middleware

RequireSession rejects a request that did not authenticate by session cookie, so a token cannot mint more tokens. It runs after Authenticate.

func Serve

func Serve(ctx context.Context, ln net.Listener, h http.Handler, log zerolog.Logger, maxDocumentSize int64) error

Serve runs h on ln until ctx is done, then gives in-flight requests shutdownGrace to finish. maxDocumentSize sizes the read timeout so the largest accepted upload fits.

Types

type Services

type Services struct {
	Tokens    *core.Tokens
	Sessions  *core.Sessions
	SignIn    *core.SignIn
	Documents *core.Documents
	Shares    *core.Shares

	// Web is the built web UI. When nil, no UI route is registered.
	Web fs.FS

	// BaseURL decides the session cookie's name and Secure flag.
	BaseURL string
	// TrustedProxies are the proxies whose X-Forwarded-For names the client.
	TrustedProxies []netip.Prefix
}

Jump to

Keyboard shortcuts

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