api

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package api provides HTTP server and API documentation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SwaggerUIHTML

func SwaggerUIHTML(specURL string) string

SwaggerUIHTML returns the HTML template for Swagger UI.

Types

type APIServer

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

APIServer provides an HTTP API backed by a kodit Client.

func NewAPIServer

func NewAPIServer(client *kodit.Client, apiKeys []string) *APIServer

NewAPIServer creates a new APIServer wired to the given kodit Client. apiKeys configures write-protection: mutating endpoints (POST, PUT, PATCH, DELETE) on /api/v1/repositories and /api/v1/enrichments require a valid key. Read-only endpoints, search, MCP, and docs remain open.

func (*APIServer) DocsRouter

func (a *APIServer) DocsRouter(specURL string) *DocsRouter

DocsRouter returns a router for Swagger UI and OpenAPI spec.

func (*APIServer) Handler

func (a *APIServer) Handler() http.Handler

Handler returns the router as an http.Handler for use with custom servers.

func (*APIServer) ListenAndServe

func (a *APIServer) ListenAndServe(addr string) error

ListenAndServe starts the HTTP server on the given address.

func (*APIServer) MountRoutes

func (a *APIServer) MountRoutes()

MountRoutes wires up all v1 API routes on the router. Call this after adding any custom middleware via Router().Use().

func (*APIServer) Router

func (a *APIServer) Router() chi.Router

Router returns the chi router for customization before starting. Call this first, add custom middleware with router.Use(), then call MountRoutes(). If not called, ListenAndServe creates a default router with all standard routes.

func (*APIServer) Shutdown

func (a *APIServer) Shutdown(ctx context.Context) error

Shutdown gracefully shuts down the server.

type DocsRouter

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

DocsRouter sets up documentation routes.

func NewDocsRouter

func NewDocsRouter(specURL string) *DocsRouter

NewDocsRouter creates a new documentation router.

func (*DocsRouter) Routes

func (d *DocsRouter) Routes() chi.Router

Routes returns the chi router for documentation endpoints.

type Server

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

Server represents the HTTP API server.

func NewServer

func NewServer(addr string, logger zerolog.Logger) Server

NewServer creates a new API Server.

func (Server) Addr

func (s Server) Addr() string

Addr returns the server address.

func (Server) Router

func (s Server) Router() chi.Router

Router returns the chi router for registering routes.

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.

Directories

Path Synopsis
Package jsonapi provides JSON:API specification compliant types for API responses.
Package jsonapi provides JSON:API specification compliant types for API responses.
Package middleware provides HTTP middleware for the API server.
Package middleware provides HTTP middleware for the API server.
v1
Package v1 provides the v1 API routes.
Package v1 provides the v1 API routes.
dto
Package dto provides data transfer objects for the API layer.
Package dto provides data transfer objects for the API layer.

Jump to

Keyboard shortcuts

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