server

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2026 License: AGPL-3.0 Imports: 23 Imported by: 0

Documentation

Overview

Package server wires the okapi HTTP application: routes, middleware, OpenAPI documentation and the embedded SPA.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsureSchema

func EnsureSchema(st *store.Store, svc *service.Service, cfg *config.Config, log *slog.Logger) error

EnsureSchema migrates the database and bootstraps the first admin.

Types

type Options

type Options struct {
	Service *service.Service
	Auth    *service.Authenticator
	Config  *config.Config
	Logger  *slog.Logger
	Version string
	// Commit and Date are the rest of the link-time build stamp, surfaced on
	// /about so an operator can tell exactly which build is running.
	Commit string
	Date   string
	// WebFS holds the built SPA. Nil serves the API only, which is what the
	// tests and a headless deployment want.
	WebFS fs.FS
	// WebRoot is the directory inside WebFS holding index.html.
	WebRoot string
}

Options configures a Server.

type Server

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

Server owns the okapi application and everything hanging off it.

func New

func New(opts Options) *Server

New builds the HTTP application.

func (*Server) Handler

func (s *Server) Handler() http.Handler

Handler exposes the router for tests and for embedding in another server.

func (*Server) Okapi

func (s *Server) Okapi() *okapi.Okapi

Okapi exposes the underlying application.

func (*Server) Start

func (s *Server) Start() error

Start runs the HTTP server until Stop is called.

func (*Server) Stop

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

Stop shuts the server down gracefully.

Directories

Path Synopsis
Package dto holds the request and response shapes of the HTTP API.
Package dto holds the request and response shapes of the HTTP API.
Package handlers implements the HTTP endpoints.
Package handlers implements the HTTP endpoints.
Package middleware holds the HTTP concerns that wrap every request: authentication, role checks and rate limiting.
Package middleware holds the HTTP concerns that wrap every request: authentication, role checks and rate limiting.

Jump to

Keyboard shortcuts

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