api

package
v0.1.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package api provides HTTP handlers for the srake REST API, exposing search, metadata retrieval, statistics, and export endpoints.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Host         string
	Port         int
	DatabasePath string
	IndexPath    string
	EnableCORS   bool
}

Config holds server configuration

type Handler

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

Handler serves the srake REST API, routing requests to the appropriate database queries and search backend operations.

func NewHandler

func NewHandler(db *database.DB, cfg *config.Config) (*Handler, error)

NewHandler creates a new Handler with all API routes registered.

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP dispatches incoming requests, adding CORS headers and handling OPTIONS preflight.

type Server

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

Server represents the HTTP API server

func NewServer

func NewServer(cfg *Config) (*Server, error)

NewServer creates a new API server instance

func (*Server) Shutdown

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

Shutdown gracefully shuts down the server

func (*Server) Start

func (s *Server) Start() error

Start starts the HTTP server

Jump to

Keyboard shortcuts

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