api

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2025 License: Apache-2.0 Imports: 22 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 Serve

func Serve(
	ctx context.Context,
	address string,
	isUnixSocket bool,
	debugMode bool,
	enableDocs bool,
	oidcConfig *auth.TokenValidatorConfig,
	middlewares ...func(http.Handler) http.Handler,
) error

Serve starts the server on the given address and serves the API. It is assumed that the caller sets up appropriate signal handling. If isUnixSocket is true, address is treated as a UNIX socket path. If oidcConfig is provided, OIDC authentication will be enabled for all API endpoints.

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.11

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

Server represents a configured HTTP server

func NewServer added in v0.2.11

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

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

func (*Server) Start added in v0.2.11

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.11

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.11

func NewServerBuilder() *ServerBuilder

NewServerBuilder creates a new ServerBuilder with default configuration

func (*ServerBuilder) Build added in v0.2.11

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

Build creates and configures the HTTP router

func (*ServerBuilder) WithAddress added in v0.2.11

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

WithAddress sets the server address

func (*ServerBuilder) WithClientManager added in v0.2.11

func (b *ServerBuilder) WithClientManager(manager client.Manager) *ServerBuilder

WithClientManager sets the client manager

func (*ServerBuilder) WithContainerRuntime added in v0.2.11

func (b *ServerBuilder) WithContainerRuntime(containerRuntime runtime.Runtime) *ServerBuilder

WithContainerRuntime sets the container runtime

func (*ServerBuilder) WithDebugMode added in v0.2.11

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

WithDebugMode enables or disables debug mode

func (*ServerBuilder) WithDocs added in v0.2.11

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

WithDocs enables or disables OpenAPI documentation

func (*ServerBuilder) WithGroupManager added in v0.2.11

func (b *ServerBuilder) WithGroupManager(manager groups.Manager) *ServerBuilder

WithGroupManager sets the group manager

func (*ServerBuilder) WithMiddleware added in v0.2.11

func (b *ServerBuilder) WithMiddleware(mw ...func(http.Handler) http.Handler) *ServerBuilder

WithMiddleware adds middleware to the server

func (*ServerBuilder) WithOIDCConfig added in v0.2.11

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

WithOIDCConfig sets the OIDC configuration

func (*ServerBuilder) WithRoute added in v0.2.11

func (b *ServerBuilder) WithRoute(prefix string, handler http.Handler) *ServerBuilder

WithRoute adds a custom route to the server

func (*ServerBuilder) WithUnixSocket added in v0.2.11

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

WithUnixSocket configures the server to use a Unix socket

func (*ServerBuilder) WithWorkloadManager added in v0.2.11

func (b *ServerBuilder) WithWorkloadManager(manager workloads.Manager) *ServerBuilder

WithWorkloadManager sets the workload manager

Directories

Path Synopsis
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