View Source SiteEncrypt.Phoenix (site_encrypt v0.5.0)
SiteEncrypt adapter for Phoenix endpoints.
usage
Usage
- Add
use SiteEncrypt.Phoenixto your endpoint immediately afteruse Phoenix.Endpoint - Configure https via
configure_https/2. - Add the implementation of
SiteEncrypt.certification/0to the endpoint (the@behaviour SiteEncryptis injected when this module is used). - Start the endpoint by providing
{SiteEncrypt.Phoenix, PhoenixDemo.Endpoint}as a supervisor child.
Link to this section 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.
Link to this section 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
# ...
endThe 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.