http

package
v2.4.15 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: MIT Imports: 29 Imported by: 0

Documentation

Overview

Package http implements the REST API server for Cortex.

It exposes observation, session, search, graph, and scoring endpoints using the standard library net/http package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Deps

type Deps struct {
	Observations      ObservationStore
	Sessions          *session.Store
	Search            *search.Store
	Prompts           *prompt.Store
	Graph             *graphstore.Store
	Scoring           *scoringstore.Store
	TemporalSnapshots *sqlitestore.TemporalSnapshotRepository
	Vectors           domain.VectorIndex
	Embeddings        embedding.Service
}

Deps bundles store dependencies for HTTP handlers.

type ObservationStore added in v2.3.10

type ObservationStore interface {
	domain.ObservationRepository
	DB() *sql.DB
	ExportAll(ctx context.Context) (*sqlitestore.ExportData, error)
	ImportData(ctx context.Context, data *sqlitestore.ExportData) (*sqlitestore.SyncImportResult, error)
}

ObservationStore captures observation persistence and data import/export capabilities required by the HTTP server.

type Options

type Options struct {
	AuthToken      string
	AllowedOrigins []string
	// WebHandler, when non-nil, serves the embedded web UI for every path not
	// owned by an explicit API or health route. It is mounted as the root
	// fallback so /api/* and /health keep their exact existing contracts.
	WebHandler http.Handler
}

Options configures optional HTTP hardening behavior.

type Server

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

Server wraps an http.Server with Cortex handlers.

func NewServer

func NewServer(addr string, deps *Deps, opts Options) *Server

NewServer creates a new HTTP server on the given address.

func (*Server) Addr

func (s *Server) Addr() string

Addr returns the server's listen address.

func (*Server) ListenAndServe

func (s *Server) ListenAndServe() error

ListenAndServe starts the HTTP server.

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context) error

Shutdown gracefully stops the server.

Jump to

Keyboard shortcuts

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