api

package
v1.9.1 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package api provides HTTP handlers for the Nexus gateway. These handlers use standard net/http and can be mounted on any HTTP router (chi, gorilla/mux, stdlib ServeMux, forge.Router).

When used with forge, the extension package wraps these with forge.Context and OpenAPI metadata.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

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

API wires all HTTP handlers for the Nexus gateway.

func New

func New(gw *nexus.Gateway, opts ...Option) *API

New creates a new API handler set. It panics when gw has no key service, which means Initialize has not run: the routes cannot be protected, and serving them open would be worse than not serving them.

func (*API) Handler

func (a *API) Handler() http.Handler

Handler returns the http.Handler for the API.

func (*API) Shutdown

func (a *API) Shutdown(_ context.Context) error

Shutdown cancels every in-flight streaming request. Use in tandem with http.Server.Shutdown so long-lived SSE/WebSocket connections drain rather than blocking the listener.

type Option

type Option func(*API)

Option configures the API handler set.

func WithStreamEncoder

func WithStreamEncoder(contentType string, enc httpstream.StreamEncoder) Option

WithStreamEncoder registers a stream encoder for content-type negotiation on streaming completion responses.

func WithWebSocket

func WithWebSocket(opts httpstream.WSOptions) Option

WithWebSocket configures the bidirectional WebSocket endpoint at /v1/realtime. Pass an empty WSOptions{} for defaults.

func WithoutWebSocket

func WithoutWebSocket() Option

WithoutWebSocket disables the /v1/realtime WebSocket endpoint.

Jump to

Keyboard shortcuts

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