api

package
v0.28.2 Latest Latest
Warning

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

Go to latest
Published: May 21, 2026 License: Apache-2.0 Imports: 41 Imported by: 0

Documentation

Overview

Package api contains the REST API for ToolHive.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DocsRouter added in v0.0.35

func DocsRouter() http.Handler

DocsRouter creates a new router for documentation endpoints.

func GenerateNonce added in v0.15.0

func GenerateNonce() (string, error)

GenerateNonce generates a random nonce for server instance identification.

func ServeOpenAPI added in v0.0.35

func ServeOpenAPI(w http.ResponseWriter, _ *http.Request)

ServeOpenAPI writes the OpenAPI specification as JSON to the response. @Summary Get OpenAPI specification @Description Returns the OpenAPI specification for the API @Tags system @Produce json @Success 200 {object} object "OpenAPI specification" @Router /api/openapi.json [get]

func ServeScalar added in v0.0.35

func ServeScalar(w http.ResponseWriter, _ *http.Request)

ServeScalar serves the Scalar API reference page

Types

type Server added in v0.2.10

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

Server represents a configured HTTP server

func NewServer added in v0.2.10

func NewServer(ctx context.Context, builder *ServerBuilder) (*Server, error)

NewServer creates a new Server instance from a pre-configured builder

func (*Server) ListenURL added in v0.13.0

func (s *Server) ListenURL() string

ListenURL returns the URL where the server is listening, using the actual bound address from the listener (important when binding to port 0).

func (*Server) Start added in v0.2.10

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

Start starts the server and blocks until the context is cancelled

type ServerBuilder added in v0.2.10

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

ServerBuilder provides a fluent interface for building and configuring the API server

func NewServerBuilder added in v0.2.10

func NewServerBuilder() *ServerBuilder

NewServerBuilder creates a new ServerBuilder with default configuration

func (*ServerBuilder) Build added in v0.2.10

func (b *ServerBuilder) Build(ctx context.Context) (*chi.Mux, error)

Build creates and configures the HTTP router

func (*ServerBuilder) WithAddress added in v0.2.10

func (b *ServerBuilder) WithAddress(address string) *ServerBuilder

WithAddress sets the server address

func (*ServerBuilder) WithDebugMode added in v0.2.10

func (b *ServerBuilder) WithDebugMode(debugMode bool) *ServerBuilder

WithDebugMode enables or disables debug mode

func (*ServerBuilder) WithDocs added in v0.2.10

func (b *ServerBuilder) WithDocs(enableDocs bool) *ServerBuilder

WithDocs enables or disables OpenAPI documentation

func (*ServerBuilder) WithNonce added in v0.13.0

func (b *ServerBuilder) WithNonce(nonce string) *ServerBuilder

WithNonce sets the server instance nonce used for discovery verification. When non-empty, the server writes a discovery file on startup and returns the nonce in the X-Toolhive-Nonce health check header.

func (*ServerBuilder) WithOIDCConfig added in v0.2.10

func (b *ServerBuilder) WithOIDCConfig(oidcConfig *auth.TokenValidatorConfig) *ServerBuilder

WithOIDCConfig sets the OIDC configuration

func (*ServerBuilder) WithOtelEnabled added in v0.15.0

func (b *ServerBuilder) WithOtelEnabled(enabled bool) *ServerBuilder

WithOtelEnabled enables OTEL HTTP middleware for distributed tracing. When enabled, the server extracts W3C traceparent headers from incoming requests and creates child OTEL spans for each request. Requires OTEL to be initialized (via telemetry.NewProvider) before the server starts.

func (*ServerBuilder) WithUnixSocket added in v0.2.10

func (b *ServerBuilder) WithUnixSocket(isUnixSocket bool) *ServerBuilder

WithUnixSocket configures the server to use a Unix socket

Directories

Path Synopsis
Package errors provides HTTP error handling utilities for the API.
Package errors provides HTTP error handling utilities for the API.
Package v1 contains the V1 API for ToolHive.
Package v1 contains the V1 API for ToolHive.

Jump to

Keyboard shortcuts

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