api

package
v0.0.0-...-36c55c0 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package api provides the REST API server and handler registration.

Index

Constants

View Source
const (
	ContextKeySubject = "auth.subject"
	ContextKeyRoles   = "auth.roles"
)

Context key constants for injecting user identity into handlers.

Variables

This section is empty.

Functions

func ScopeMiddleware

func ScopeMiddleware(
	handler strictecho.StrictEchoHandlerFunc,
	tokenManager TokenValidator,
	signingKey string,
	contextKey string,
	customRoles map[string][]string,
) strictecho.StrictEchoHandlerFunc

ScopeMiddleware validates JWT tokens and checks for required permissions.

Types

type Option

type Option func(*Server)

Option is a functional option for configuring the Server.

func WithAuditStore

func WithAuditStore(
	store audit.Store,
) Option

WithAuditStore sets the audit store for audit middleware.

func WithMeterProvider

func WithMeterProvider(
	mp *sdkmetric.MeterProvider,
) Option

WithMeterProvider sets the OTEL MeterProvider for HTTP metrics. When set, the otelecho middleware routes metrics to this provider instead of the global provider.

type Server

type Server struct {
	Echo *echo.Echo
	// contains filtered or unexported fields
}

Server implementation of the Server's API operations.

func New

func New(
	appConfig config.Config,
	logger *slog.Logger,
	opts ...Option,
) *Server

New initialize a new Server and configure an Echo server.

func (*Server) RegisterHandlers

func (s *Server) RegisterHandlers(
	handlers []func(e *echo.Echo),
)

RegisterHandlers registers a list of handlers with the Echo instance.

func (*Server) Start

func (s *Server) Start()

Start starts the Echo server with the configured port.

func (*Server) Stop

func (s *Server) Stop(
	ctx context.Context,
)

Stop gracefully shuts down the Echo server.

type TokenValidator

type TokenValidator interface {
	Validate(
		tokenString string,
		signingKey string,
	) (*authtoken.CustomClaims, error)
}

TokenValidator parses and validates JWT tokens.

Directories

Path Synopsis
Package agent provides agent-related API handlers.
Package agent provides agent-related API handlers.
gen
Package gen provides primitives to interact with the openapi HTTP API.
Package gen provides primitives to interact with the openapi HTTP API.
Package audit provides audit log API handlers.
Package audit provides audit log API handlers.
gen
Package gen provides primitives to interact with the openapi HTTP API.
Package gen provides primitives to interact with the openapi HTTP API.
common
gen
Package gen provides primitives to interact with the openapi HTTP API.
Package gen provides primitives to interact with the openapi HTTP API.
Package facts provides fact key discovery API handlers.
Package facts provides fact key discovery API handlers.
gen
Package gen provides primitives to interact with the openapi HTTP API.
Package gen provides primitives to interact with the openapi HTTP API.
Package file provides file management API handlers.
Package file provides file management API handlers.
gen
Package gen provides primitives to interact with the openapi HTTP API.
Package gen provides primitives to interact with the openapi HTTP API.
mocks
Package mocks provides mock implementations for testing.
Package mocks provides mock implementations for testing.
Package health provides health check API handlers.
Package health provides health check API handlers.
gen
Package gen contains generated code for the health API.
Package gen contains generated code for the health API.
mocks
Package mocks provides mock implementations for testing.
Package mocks provides mock implementations for testing.
job
Package job provides job queue API handlers.
Package job provides job queue API handlers.
gen
Package gen contains generated code for the job API.
Package gen contains generated code for the job API.
Package node provides node-related API handlers.
Package node provides node-related API handlers.
certificate
Package certificate provides certificate-related API handlers.
Package certificate provides certificate-related API handlers.
certificate/gen
Package gen provides primitives to interact with the openapi HTTP API.
Package gen provides primitives to interact with the openapi HTTP API.
command
Package command provides command execution API handlers.
Package command provides command execution API handlers.
command/gen
Package gen provides primitives to interact with the openapi HTTP API.
Package gen provides primitives to interact with the openapi HTTP API.
docker
Package container provides container-related API handlers.
Package container provides container-related API handlers.
docker/gen
Package gen provides primitives to interact with the openapi HTTP API.
Package gen provides primitives to interact with the openapi HTTP API.
file
Package file provides node-targeted file deploy API handlers.
Package file provides node-targeted file deploy API handlers.
file/gen
Package gen provides primitives to interact with the openapi HTTP API.
Package gen provides primitives to interact with the openapi HTTP API.
gen
Package gen contains generated code for the node API.
Package gen contains generated code for the node API.
hostname
Package hostname provides hostname-related API handlers.
Package hostname provides hostname-related API handlers.
hostname/gen
Package gen contains generated code for the hostname API.
Package gen contains generated code for the hostname API.
log
Package log provides log management API handlers.
Package log provides log management API handlers.
log/gen
Package gen contains generated code for the log API.
Package gen contains generated code for the log API.
network
Package network provides network-related API handlers.
Package network provides network-related API handlers.
network/gen
Package gen contains generated code for the network API.
Package gen contains generated code for the network API.
ntp
Package ntp provides NTP-related API handlers.
Package ntp provides NTP-related API handlers.
ntp/gen
Package gen contains generated code for the NTP API.
Package gen contains generated code for the NTP API.
package
Package packageapi provides package-management-related API handlers.
Package packageapi provides package-management-related API handlers.
package/gen
Package gen contains generated code for the package management API.
Package gen contains generated code for the package management API.
power
Package power provides power management API handlers.
Package power provides power management API handlers.
power/gen
Package gen contains generated code for the Power API.
Package gen contains generated code for the Power API.
process
Package process provides process management API handlers.
Package process provides process management API handlers.
process/gen
Package gen contains generated code for the process API.
Package gen contains generated code for the process API.
schedule
Package schedule provides schedule-related API handlers.
Package schedule provides schedule-related API handlers.
schedule/gen
Package gen contains generated code for the schedule API.
Package gen contains generated code for the schedule API.
service
Package service provides service-related API handlers.
Package service provides service-related API handlers.
service/gen
Package gen contains generated code for the service API.
Package gen contains generated code for the service API.
sysctl
Package sysctl provides sysctl-related API handlers.
Package sysctl provides sysctl-related API handlers.
sysctl/gen
Package gen contains generated code for the sysctl API.
Package gen contains generated code for the sysctl API.
timezone
Package timezone provides timezone-related API handlers.
Package timezone provides timezone-related API handlers.
timezone/gen
Package gen contains generated code for the Timezone API.
Package gen contains generated code for the Timezone API.
user
Package user provides user and group API handlers.
Package user provides user and group API handlers.
user/gen
Package gen contains generated code for the user and group API.
Package gen contains generated code for the user and group API.
Package ui provides the HTTP handler for serving the embedded React UI.
Package ui provides the HTTP handler for serving the embedded React UI.

Jump to

Keyboard shortcuts

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