caddy

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DestroySessionRoutes

func DestroySessionRoutes(sessionName string, routes map[string]string) error

DestroySessionRoutes removes all Caddy routes for a session

func GetServiceMapping

func GetServiceMapping(portName string) string

GetServiceMapping maps port environment variable names to service names

func NormalizeDNSName

func NormalizeDNSName(serviceName string) string

NormalizeDNSName converts a service name to be DNS-compatible

func ProvisionSessionRoutes

func ProvisionSessionRoutes(sessionName string, services map[string]int) (map[string]string, error)

ProvisionSessionRoutes creates Caddy routes for all services in a session

func ProvisionSessionRoutesWithProject

func ProvisionSessionRoutesWithProject(sessionName string, services map[string]int, projectAlias string) (map[string]string, error)

ProvisionSessionRoutesWithProject creates Caddy routes for all services in a session with optional project prefix

func RepairRoutes

func RepairRoutes(result *HealthCheckResult, sessions map[string]*SessionInfo) error

RepairRoutes attempts to fix any routing issues found during health check

func SanitizeHostname

func SanitizeHostname(sessionName string) string

SanitizeHostname converts a session name to be hostname-compatible

Types

type CaddyClient

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

CaddyClient manages communication with Caddy's admin API

func NewCaddyClient

func NewCaddyClient() *CaddyClient

NewCaddyClient creates a new Caddy API client

func (*CaddyClient) CheckCaddyConnection

func (c *CaddyClient) CheckCaddyConnection() error

CheckCaddyConnection verifies that Caddy is running and accessible

func (*CaddyClient) CreateRoute

func (c *CaddyClient) CreateRoute(sessionName, serviceName string, port int) (string, error)

CreateRoute creates a route for a service

func (*CaddyClient) CreateRouteWithProject

func (c *CaddyClient) CreateRouteWithProject(sessionName, serviceName string, port int, projectAlias string) (string, error)

CreateRouteWithProject creates a route for a service with optional project prefix

func (*CaddyClient) DeleteRoute

func (c *CaddyClient) DeleteRoute(routeID string) error

DeleteRoute deletes a route by ID

func (*CaddyClient) DeleteSessionRoutes

func (c *CaddyClient) DeleteSessionRoutes(sessionName string) error

DeleteSessionRoutes deletes all routes for a session

func (*CaddyClient) GetAllRoutes

func (c *CaddyClient) GetAllRoutes() ([]Route, error)

GetAllRoutes retrieves all routes from Caddy

func (*CaddyClient) ReplaceAllRoutes

func (c *CaddyClient) ReplaceAllRoutes(routes []Route) error

ReplaceAllRoutes deletes all current routes and creates new ones in the specified order

type HealthCheckResult

type HealthCheckResult struct {
	CaddyRunning   bool
	CaddyError     string
	RouteStatuses  []RouteStatus
	CatchAllFirst  bool // Whether catch-all route is blocking specific routes
	RoutesNeeded   int
	RoutesExisting int
	RoutesWorking  int
}

HealthCheckResult contains the overall Caddy health status

func CheckCaddyHealth

func CheckCaddyHealth(sessions map[string]*SessionInfo) (*HealthCheckResult, error)

CheckCaddyHealth performs a comprehensive health check of Caddy and all routes

type Route

type Route struct {
	ID       string         `json:"@id"`
	Match    []RouteMatch   `json:"match"`
	Handle   []RouteHandler `json:"handle"`
	Terminal bool           `json:"terminal"`
}

Route represents a Caddy route configuration

type RouteHandler

type RouteHandler struct {
	Handler   string          `json:"handler"`
	Upstreams []RouteUpstream `json:"upstreams,omitempty"`
}

RouteHandler represents a route handler

type RouteMatch

type RouteMatch struct {
	Host []string `json:"host"`
}

RouteMatch represents the match criteria for a route

type RouteResponse

type RouteResponse struct {
	ETag string `json:"etag,omitempty"`
}

RouteResponse represents the response from Caddy when creating/updating routes

type RouteStatus

type RouteStatus struct {
	SessionName string
	ServiceName string
	RouteID     string
	Hostname    string
	Port        int
	Exists      bool
	IsFirst     bool // Whether route appears before catch-all
	ServiceUp   bool // Whether the service is responding
	Error       string
}

RouteStatus represents the status of a Caddy route

type RouteUpstream

type RouteUpstream struct {
	Dial string `json:"dial"`
}

RouteUpstream represents an upstream server

type SessionInfo

type SessionInfo struct {
	Name         string
	Ports        map[string]int
	ProjectAlias string
}

SessionInfo represents basic session information needed for health checks

Jump to

Keyboard shortcuts

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