View Source SiteEncrypt.Phoenix (site_encrypt v0.5.1)
SiteEncrypt
adapter for Phoenix endpoints.
Usage
- Add
use SiteEncrypt.Phoenix
to your endpoint immediately afteruse Phoenix.Endpoint
- Configure https via
configure_https/2
. - Add the implementation of
SiteEncrypt.certification/0
to the endpoint (the@behaviour SiteEncrypt
is injected when this module is used). - Start the endpoint by providing
{SiteEncrypt.Phoenix, PhoenixDemo.Endpoint}
as a supervisor child.
Summary
Functions
Returns a specification to start this module under a supervisor.
Merges paths to key and certificates to the :https
configuration of the endpoint config for Cowboy.
Starts the endpoint managed by SiteEncrypt
.
Functions
@spec child_spec(endpoint :: module()) :: Supervisor.child_spec()
Returns a specification to start this module under a supervisor.
See Supervisor
.
Merges paths to key and certificates to the :https
configuration of the endpoint config for Cowboy.
Invoke this macro from Phoenix.Endpoint.init/2
to complete the https configuration:
defmodule MyEndpoint do
# ...
@impl Phoenix.Endpoint
def init(_key, config) do
# this will merge key, cert, and chain into `:https` configuration from config.exs
{:ok, SiteEncrypt.Phoenix.configure_https(config)}
# to completely configure https from `init/2`, invoke:
# SiteEncrypt.Phoenix.configure_https(config, port: 4001, ...)
end
# ...
end
The options
are any valid adapter HTTPS options. For many great tips on configuring HTTPS for
production refer to the Plug HTTPS guide.
@spec start_link(endpoint :: module()) :: Supervisor.on_start()
Starts the endpoint managed by SiteEncrypt
.