handler

package
v0.0.0-...-e083d15 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package handler implements the API gateway's HTTP endpoints. It proxies requests to the ingestion and search services via httputil.ReverseProxy and exposes direct PostgreSQL-backed endpoints for document listing, document retrieval, and API key management.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	IngestionURL string
	SearcherURL  string
}

Config holds the URLs of backend services that the gateway proxies to.

type Handler

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

Handler implements the API gateway's HTTP endpoints. It proxies requests to backend services and provides direct document retrieval and API key management via PostgreSQL.

func New

func New(cfg Config, db *postgres.Client, keyValidator *apikey.Validator) *Handler

New creates a gateway Handler that proxies to the given backend URLs.

func (*Handler) CreateAPIKey

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

CreateAPIKey creates a new API key and returns the raw key (shown once).

func (*Handler) GetDocument

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

GetDocument retrieves a single document's metadata from PostgreSQL by UUID.

func (*Handler) Health

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

Health returns the gateway's health status.

func (*Handler) ListAPIKeys

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

ListAPIKeys returns all active API keys (without hashes).

func (*Handler) ListDocuments

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

ListDocuments returns a paginated list of document metadata.

func (*Handler) ProxyAnalytics

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

ProxyAnalytics forwards analytics requests to the search service.

func (*Handler) ProxyCacheInvalidate

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

ProxyCacheInvalidate forwards cache invalidation requests to the search service.

func (*Handler) ProxyCacheStats

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

ProxyCacheStats forwards cache stats requests to the search service.

func (*Handler) ProxyIngest

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

ProxyIngest forwards document ingestion requests to the ingestion service.

func (*Handler) ProxySearch

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

ProxySearch forwards search queries to the search service.

Jump to

Keyboard shortcuts

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