Documentation
¶
Index ¶
- Constants
- func MarshalApps(apps AppMap) (map[string]json.RawMessage, error)
- func RegisterModule(module Module)
- type ActiveHealthCheck
- type AdminConfig
- type AppMap
- type AutoHTTPS
- type Client
- func (c *Client) DeleteConfig(ctx context.Context, path string) error
- func (c *Client) GetConfig(ctx context.Context) (*Config, error)
- func (c *Client) GetConfigByID(ctx context.Context, id string, v any) error
- func (c *Client) GetConfigByPath(ctx context.Context, path string, v any) error
- func (c *Client) Load(ctx context.Context, cfg *Config) error
- func (c *Client) PatchConfig(ctx context.Context, path string, cfg any) error
- func (c *Client) PostConfig(ctx context.Context, path string, cfg any) error
- func (c *Client) PutConfig(ctx context.Context, path string, cfg any) error
- type Config
- type FileStorage
- type HTTP
- type Handler
- type HealthChecks
- type Logging
- type MatcherSet
- type Module
- type ModuleInfo
- type ReverseProxy
- type Route
- type Server
- type Storage
- type TLS
- type Upstream
Constants ¶
const DefaultServerAddr = "http://localhost:2019"
DefaultServerAddr is the default address for a Caddy API server.
Variables ¶
This section is empty.
Functions ¶
func MarshalApps ¶
func MarshalApps(apps AppMap) (map[string]json.RawMessage, error)
MarshalApps marshals a map of app modules to raw JSON messages.
func RegisterModule ¶
func RegisterModule(module Module)
RegisterModule adds a module to the registry by it's ID. Registering a module makes it available for lookup when unmarshalling config.
Types ¶
type ActiveHealthCheck ¶
type AdminConfig ¶
type AdminConfig struct { ID string `json:"@id,omitempty"` Disabled bool `json:"disabled"` Listen string `json:"listen,omitempty"` }
AdminConfig configures Caddy's API endpoint, which is used to manage Caddy while it is running.
type AppMap ¶
AppMap is a map of app names to app modules.
func UnmarshalApps ¶
func UnmarshalApps(rawApps map[string]json.RawMessage) (AppMap, error)
UnmarshalApps unmarshals a map of app modules.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client provides an API client for the Caddy server.
func NewSocketClient ¶
NewSocketClient creates a new Caddy API client using a unix socket.
func (*Client) DeleteConfig ¶
DeleteConfig removes Caddy's configuration at the named path.
func (*Client) GetConfigByID ¶
Exports Caddy's current configuration with the given ID. The configuration will be unmarshalled into v.
func (*Client) GetConfigByPath ¶
Exports Caddy's current configuration at the named path. The configuration will be unmarshalled into v.
func (*Client) PatchConfig ¶
PatchConfig hanges Caddy's configuration at the named path using PATCH semantics.
func (*Client) PostConfig ¶
PostConfig changes Caddy's configuration at the named path using POST semantics.
type Config ¶
type Config struct { Admin *AdminConfig `json:"admin,omitempty"` Logging *Logging `json:"logging,omitempty"` Storage Module `json:"-"` StorageRaw json.RawMessage `json:"storage,omitempty"` Apps map[string]Module `json:"-"` AppsRaw map[string]json.RawMessage `json:"apps,omitempty"` }
Config defines the Caddy configuration structure.
func (Config) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
func (*Config) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
type FileStorage ¶
type FileStorage struct { Storage ID string `json:"@id,omitempty"` Root string `json:"root,omitempty"` }
FileStorage configures a local filesystem for certificate storage.
func NewFileStorage ¶
func NewFileStorage(root string) FileStorage
func (FileStorage) CaddyModule ¶
func (s FileStorage) CaddyModule() ModuleInfo
CaddyModule implements Module.
type HTTP ¶
type HTTP struct { ID string `json:"@id,omitempty"` HTTPPort int `json:"http_port,omitempty"` HTTPSPort int `json:"https_port,omitempty"` GracePeriod time.Duration `json:"grace_period,omitempty"` ShutdownDelay time.Duration `json:"shutdown_delay,omitempty"` Servers map[string]Server `json:"servers,omitempty"` }
The HTTP app provides a robust, production-ready HTTP server.
type HealthChecks ¶
type HealthChecks struct { ID string `json:"@id,omitempty"` Active *ActiveHealthCheck `json:"active,omitempty"` }
type Logging ¶
type Logging struct {
ID string `json:"@id,omitempty"`
}
Logging configures logging within Caddy.
type MatcherSet ¶
type MatcherSet struct { ID string `json:"@id,omitempty"` Host []string `json:"host,omitempty"` Path []string `json:"path,omitempty"` }
MatcherSet is used to qualify a route for a request.
type Module ¶
type Module interface {
CaddyModule() ModuleInfo
}
Module provides configuration for a Caddy module.
func UnmarshalHandler ¶
UnmarshalHandler unmarshals a handler module.
func UnmarshalStorage ¶
UnmarshalStorage unmarshals a storage module.
type ModuleInfo ¶
type ModuleInfo struct { // ID is a unique, namespaced identifier for the module. // Caddy IDs are dot separated and use snake_case by convention. // For example, `caddy.storage.file_system` is a module with the // name "file_system" in the namespace "caddy.storage". ID string // New returns a pointer to a new, empty instance of the module's type. New func() Module }
ModuleInfo describes a Caddy module.
func GetModule ¶
func GetModule(id string) (ModuleInfo, error)
GetModule returns module info for the given ID, if found.
type ReverseProxy ¶
type ReverseProxy struct { Handler Upstreams []Upstream `json:"upstreams,omitempty"` HealthChecks *HealthChecks `json:"health_checks,omitempty"` TrustedProxies []string `json:"trusted_proxies,omitempty"` }
ReverseProxy configures a highly configurable and production-ready reverse proxy.
func NewReverseProxy ¶
func NewReverseProxy() ReverseProxy
func (ReverseProxy) CaddyModule ¶
func (s ReverseProxy) CaddyModule() ModuleInfo
CaddyModule implements Module.
type Route ¶
type Route struct { ID string `json:"@id,omitempty"` Group string `json:"group,omitempty"` Handle []Module `json:"-"` HandleRaw []json.RawMessage `json:"handle"` Match []MatcherSet `json:"match"` }
Route consists of a set of rules for matching HTTP requests, a list of handlers to execute, and optional flow control parameters which customize the handling of HTTP requests in a highly flexible and performant manner.
func (Route) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
func (*Route) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
type Server ¶
type Server struct { ID string `json:"@id,omitempty"` Listen []string `json:"listen"` ReadTimeout time.Duration `json:"read_timeout,omitempty"` ReadHeaderTimeout time.Duration `json:"read_header_timeout,omitempty"` WriteTimeout time.Duration `json:"write_timeout,omitempty"` IdleTimeout time.Duration `json:"idle_timeout,omitempty"` KeepAliveInterval time.Duration `json:"keepalive_interval,omitempty"` MaxHeaderBytes int `json:"max_header_bytes,omitempty"` Routes []Route `json:"routes,omitempty"` AutoHTTPS *AutoHTTPS `json:"automatic_https,omitempty"` }
Server describes an HTTP server.