caddy

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildExternalHostname added in v0.3.0

func BuildExternalHostname(sessionName, serviceName, projectAlias, domain string) string

BuildExternalHostname constructs the hostname for a session/service on an external domain. Returns "" if the service name normalizes to empty or domain is empty.

func BuildHostname added in v0.2.0

func BuildHostname(sessionName, serviceName, projectAlias string) string

BuildHostname constructs the hostname for a session/service combination. Returns "" if the service name normalizes to empty. Labels are capped at 63 characters per RFC 1035; longer labels are truncated with a 4-character hash appended to preserve uniqueness.

func BuildRouteID added in v0.2.0

func BuildRouteID(sessionName, serviceName, projectAlias string) string

BuildRouteID constructs the route ID for a session/service combination. Returns "" if the service name normalizes to empty.

func NormalizeDNSName

func NormalizeDNSName(serviceName string) string

NormalizeDNSName converts a service name to be DNS-compatible

func SanitizeHostname

func SanitizeHostname(sessionName string) string

SanitizeHostname converts a session name to be hostname-compatible. Unlike NormalizeDNSName, it also converts slashes to hyphens (for branch names like "feature/foo").

func SyncRoutes added in v0.2.0

func SyncRoutes(sessions map[string]*SessionInfo) error

SyncRoutes generates the Caddy config file and reloads Caddy. It writes the config even if Caddy is not running, so the next Caddy start picks up the correct routes.

Types

type CaddyAdmin added in v0.2.0

type CaddyAdmin struct {
	Listen string `json:"listen"`
}

CaddyAdmin represents the admin API configuration

type CaddyApps added in v0.2.0

type CaddyApps struct {
	HTTP CaddyHTTP `json:"http"`
}

CaddyApps contains the HTTP app configuration

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) GetAllRoutes

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

GetAllRoutes retrieves all routes from Caddy

type CaddyConfig added in v0.2.0

type CaddyConfig struct {
	Admin CaddyAdmin `json:"admin"`
	Apps  CaddyApps  `json:"apps"`
}

CaddyConfig represents the full Caddy JSON configuration

func BuildCaddyConfig added in v0.2.0

func BuildCaddyConfig(sessions map[string]*SessionInfo) CaddyConfig

BuildCaddyConfig generates the complete Caddy JSON config from session data

type CaddyHTTP added in v0.2.0

type CaddyHTTP struct {
	Servers map[string]CaddyServer `json:"servers"`
}

CaddyHTTP contains the HTTP server configuration

type CaddyServer added in v0.2.0

type CaddyServer struct {
	Listen []string `json:"listen"`
	Routes []Route  `json:"routes"`
}

CaddyServer represents a single HTTP server

type HealthCheckResult

type HealthCheckResult struct {
	CaddyRunning   bool
	CaddyError     string
	RouteStatuses  []RouteStatus
	RoutesNeeded   int
	RoutesExisting 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"`
	Headers   *RouteHeaders   `json:"headers,omitempty"`
}

RouteHandler represents a route handler

type RouteHeaderOps added in v0.3.0

type RouteHeaderOps struct {
	Set map[string][]string `json:"set,omitempty"`
}

RouteHeaderOps holds header set/add/delete operations.

type RouteHeaders added in v0.3.0

type RouteHeaders struct {
	Request *RouteHeaderOps `json:"request,omitempty"`
}

RouteHeaders configures header manipulation in a reverse_proxy handler.

type RouteMatch

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

RouteMatch represents the match criteria for a route

type RouteStatus

type RouteStatus struct {
	SessionName string
	ServiceName string
	RouteID     string
	Hostname    string
	Port        int
	Exists      bool
	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