Plug adapter for Gale HTTP/1.1, HTTP/2, and HTTP/3.
This module provides a drop-in replacement for Plug.Cowboy and Plug.Adapters.Bandit,
allowing any Plug-based application to run on Gale:
defmodule MyApp do
use Plug.Builder
plug :match
plug :dispatch
get "/" do
send_resp(conn, 200, "Hello from Gale!")
end
endThen start it:
# Start Gale with your Plug
children = [
{Gale.Plug, plug: MyApp, port: 4000}
]
Supervisor.start_link(children, strategy: :one_for_one)Options
:scheme-:httpor:https(default::http):plug- The Plug module or{module, opts}tuple:port- Port to listen on (default: 4000):ip- IP address to bind to:http3- Enable HTTP/3 (requires HTTPS with certs):certfile- Path to SSL certificate:keyfile- Path to SSL private key
Phoenix Integration
For Phoenix applications, use Gale.PhoenixAdapter instead:
config :my_app, MyAppWeb.Endpoint,
adapter: Gale.PhoenixAdapter
Summary
Functions
Returns a child_spec for Gale server.
Returns child specs for HTTP and HTTPS listeners.
Starts Gale server for the given Plug.
Functions
@spec child_spec(keyword()) :: Supervisor.child_spec()
Returns a child_spec for Gale server.
Use this in your supervision tree:
children = [
{Gale.Plug, plug: MyPlug, port: 4000}
]
@spec child_specs(keyword()) :: [Supervisor.child_spec()]
Returns child specs for HTTP and HTTPS listeners.
Use this when you need separate HTTP/HTTPS child specs:
children = Gale.Plug.child_specs(
plug: MyPlug,
http: [port: 4000],
https: [port: 4443, certfile: "cert.pem", keyfile: "key.pem"],
http3: true
)
Starts Gale server for the given Plug.