Documentation
¶
Overview ¶
Package api contains the REST API for ToolHive.
Index ¶
- func DocsRouter() http.Handler
- func Serve(ctx context.Context, address string, isUnixSocket bool, debugMode bool, ...) error
- func ServeOpenAPI(w http.ResponseWriter, _ *http.Request)
- func ServeScalar(w http.ResponseWriter, _ *http.Request)
- type Server
- type ServerBuilder
- func (b *ServerBuilder) Build(ctx context.Context) (*chi.Mux, error)
- func (b *ServerBuilder) WithAddress(address string) *ServerBuilder
- func (b *ServerBuilder) WithClientManager(manager client.Manager) *ServerBuilder
- func (b *ServerBuilder) WithContainerRuntime(containerRuntime runtime.Runtime) *ServerBuilder
- func (b *ServerBuilder) WithDebugMode(debugMode bool) *ServerBuilder
- func (b *ServerBuilder) WithDocs(enableDocs bool) *ServerBuilder
- func (b *ServerBuilder) WithGroupManager(manager groups.Manager) *ServerBuilder
- func (b *ServerBuilder) WithMiddleware(mw ...func(http.Handler) http.Handler) *ServerBuilder
- func (b *ServerBuilder) WithOIDCConfig(oidcConfig *auth.TokenValidatorConfig) *ServerBuilder
- func (b *ServerBuilder) WithRoute(prefix string, handler http.Handler) *ServerBuilder
- func (b *ServerBuilder) WithUnixSocket(isUnixSocket bool) *ServerBuilder
- func (b *ServerBuilder) WithWorkloadManager(manager workloads.Manager) *ServerBuilder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DocsRouter ¶ added in v0.0.35
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
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