Caddy.Config (Caddy v2.0.7)

View Source

Start Caddy Config process to manage Caddy configuration.

Configuration is stored in %Caddy.Config{} struct in Caddy.Config process.

%Caddy.Config{
  bin: binary() | nil,
  global: binary(),
  additional: [binary()],
  sites: map(),
  env: list({binary(), binary()})
}

Summary

Functions

Convert caddyfile to json format.

Returns a specification to start this module under a supervisor.

Get the :key in Caddy Cofnig

Return the current configuration in Caddy.Config

Callback implementation for GenServer.init/1.

Set the Caddy binary path

Set the caddy binary path and restart Caddy.Server

Replace the current configuration in Caddy.Config

Set the global configuration

Set the site configuration

Confirt %Caddy.Config{} to caddyfile()

Types

caddyfile()

@type caddyfile() :: binary()

site_config()

@type site_config() :: caddyfile() | {site_listen(), caddyfile()}

site_listen()

@type site_listen() :: binary()

site_name()

@type site_name() :: binary()

t()

@type t() :: %Caddy.Config{
  additional: [binary()],
  bin: binary() | nil,
  env: [{binary(), binary()}],
  global: binary(),
  sites: map()
}

Functions

adapt(binary)

@spec adapt(caddyfile()) :: {:ok, map()} | {:error, term()}

Convert caddyfile to json format.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

env_file()

etc_path()

get(name)

@spec get(atom()) :: binary() | nil

Get the :key in Caddy Cofnig

get_config()

@spec get_config() :: t()

Return the current configuration in Caddy.Config

init(args)

@spec init(keyword()) ::
  {:ok,
   %Caddy.Config{
     additional: term(),
     bin: term(),
     env: term(),
     global: term(),
     sites: term()
   }}

Callback implementation for GenServer.init/1.

init_file()

pid_file()

priv_path()

run_path()

saved()

saved_json_file()

set_additional(additionals)

set_bin(caddy_bin)

@spec set_bin(binary()) :: {:ok, binary()} | {:error, term()}

Set the Caddy binary path

set_bin!(caddy_bin)

@spec set_bin!(binary()) :: :ok | {:error, term()}

Set the caddy binary path and restart Caddy.Server

set_config(config)

@spec set_config(t()) :: {:ok, t()} | {:error, term()}

Replace the current configuration in Caddy.Config

set_global(global)

@spec set_global(caddyfile()) :: {:ok, caddyfile()} | {:error, term()}

Set the global configuration

Caddy.Config.set_global("""
debug
auto_https off
""")

set_site(name, site)

@spec set_site(site_name(), site_config()) ::
  {:ok, site_name(), site_config()} | {:error, term()}

Set the site configuration

Caddy.Config.set_site("www.gsmlg.com", """
reverse_proxy {
  to localhost:4000
  header_up host www.gsmlg.com
  header_up X-Real-IP {remote_host}
}
""")
# or
Caddy.Config.set_site("proxy", {":8080", """
reverse_proxy {
  to localhost:3128
}
"""})

share_path()

socket_file()

start_link(args)

tmp_path()

to_caddyfile(config)

@spec to_caddyfile(t()) :: caddyfile()

Confirt %Caddy.Config{} to caddyfile()

user_home()

See System.user_home/0.

user_share()

xdg_config_home()

xdg_data_home()