View Source Bandit.PhoenixAdapter (Bandit v0.5.7)
A Bandit adapter for Phoenix.
WebSocket support requires a version of Phoenix with Plug upgrade support, which is available as part of Phoenix 1.7 and later. This module will work fine on earlier versions of Phoenix, just without WebSocket support.
To use this adapter, your project will need to include Bandit as a dependency; see
https://hex.pm/bandit for details on the currently supported version of Bandit to include. Once
Bandit is included as a dependency of your Phoenix project, add the following to your endpoint
configuration in config/config.exs
:
config :your_app, YourAppWeb.Endpoint,
adapter: Bandit.PhoenixAdapter
endpoint-configuration
Endpoint configuration
This adapter uses the following endpoint configuration:
:http
: the configuration for the HTTP server. Accepts the following options:port
: The port to run on. Defaults to 4000ip
: The address to bind to. Can be specified as{127, 0, 0, 1}
, or using{:local, path}
to bind to a Unix domain socket. Defaults to {127, 0, 0, 1}.transport_options
: Any valid value fromThousandIsland.Transports.TCP
Defaults to
false
, which will cause Bandit to not start an HTTP server.:https
: the configuration for the HTTPS server. Accepts the following options:port
: The port to run on. Defaults to 4040ip
: The address to bind to. Can be specified as{127, 0, 0, 1}
, or using{:local, path}
to bind to a Unix domain socket. Defaults to {127, 0, 0, 1}.transport_options
: Any valid value fromThousandIsland.Transports.SSL
Defaults to
false
, which will cause Bandit to not start an HTTPS server.