server

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2026 License: MIT Imports: 29 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Param

func Param(r *http.Request, name string) string

Param fetches a path parameter from a request, or "" if missing.

Types

type AIAdvisor

type AIAdvisor interface {
	Enabled() bool
	Status() map[string]any
	Analyze(ctx context.Context, prompt string) (*ai.AnalyzeResult, error)
	Chat(ctx context.Context, message string) (*ai.AnalyzeResult, error)
	BackgroundState() ai.BackgroundState
}

AIAdvisor is the minimal interface the server needs from the AI package.

type Options

type Options struct {
	Cfg        *config.Config
	CfgPath    string
	OnCfgApply func(*config.Config) // invoked after a successful in-process config update
	Store      *storage.Store
	Controller *controller.Controller
	Alerts     *anomaly.AlertStore
	Emitter    *event.Emitter
	Advisor    AIAdvisor
	StaticFS   fs.FS
	Version    string
}

Options bundles every dependency the Server needs.

type Params

type Params map[string]string

Params is the map of named path parameters extracted from a route.

type Router

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

Router is a tiny method+path router that supports `:param` segments.

func NewRouter

func NewRouter() *Router

func (*Router) DELETE

func (rt *Router) DELETE(p string, h http.HandlerFunc)

func (*Router) GET

func (rt *Router) GET(p string, h http.HandlerFunc)

func (*Router) Handle

func (rt *Router) Handle(method, pattern string, h http.HandlerFunc)

Handle registers a handler for a method+pattern.

func (*Router) POST

func (rt *Router) POST(p string, h http.HandlerFunc)

func (*Router) PUT

func (rt *Router) PUT(p string, h http.HandlerFunc)

func (*Router) ServeHTTP

func (rt *Router) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements http.Handler.

func (*Router) SetNotFound

func (rt *Router) SetNotFound(h http.HandlerFunc)

SetNotFound overrides the default 404 handler.

func (*Router) Use

func (rt *Router) Use(mw func(http.HandlerFunc) http.HandlerFunc)

Use appends a middleware that wraps every handler.

type SSEHub

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

SSEHub fans out emitter events to all connected SSE clients. It throttles per-event-type to avoid overwhelming slow clients.

func NewSSEHub

func NewSSEHub(emitter *event.Emitter) *SSEHub

func (*SSEHub) ClientCount

func (h *SSEHub) ClientCount() int

ClientCount returns the number of active SSE clients.

func (*SSEHub) Handler

func (h *SSEHub) Handler() http.HandlerFunc

Handler returns the SSE HTTP handler.

type Server

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

Server is the HTTP server hosting the REST API, SSE stream, and embedded UI.

func New

func New(opts Options) *Server

func (*Server) ExecuteAISuggestion added in v0.2.0

func (s *Server) ExecuteAISuggestion(suggestion ai.Suggestion, confirm bool) error

func (*Server) SetConfig

func (s *Server) SetConfig(cfg *config.Config)

SetConfig hot-swaps the active config (after a watcher reload).

func (*Server) Shutdown

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

Shutdown gracefully terminates the HTTP server.

func (*Server) Start

func (s *Server) Start() error

Start begins serving HTTP. Returns when the listener exits.

Jump to

Keyboard shortcuts

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