Plug.Cowboy.child_spec
You're seeing just the function
child_spec
, go back to Plug.Cowboy module for more information.
A function for starting a Cowboy2 server under Elixir v1.5+ supervisors.
It supports all options as specified in the module documentation plus it requires the follow two options:
:scheme
- either:http
or:https
:plug
- such asMyPlug
or{MyPlug, plug_opts}
Examples
Assuming your Plug module is named MyApp
you can add it to your
supervision tree by using this function:
children = [
{Plug.Cowboy, scheme: :http, plug: MyApp, options: [port: 4040]}
]
Supervisor.start_link(children, strategy: :one_for_one)