View Source Bandit.PhoenixAdapter (Bandit v0.5.6)

A Bandit adapter for Phoenix.

WebSocket support requires a version of Phoenix with Sock support. This is currently (Sept 2022) a work in progress. 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 4000
    • ip: 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 from ThousandIsland.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 4040
    • ip: 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 from ThousandIsland.Transports.SSL

    Defaults to false, which will cause Bandit to not start an HTTPS server.