BastionServer
BastionServer — convenience wrappers for starting a Bastion HTTP server.
Usage:
fn main() do
let router = build_router()
BastionServer.start(router, Bastion.default_opts(4000))
endFunctions
Start the server in a subprocess that handles exactly n requests, then exits. Returns an integer handle that can be passed to BastionServer.wait_for/1. Useful for integration tests — lets the test drive request count.
Start the Bastion server with the given router and options.
Converts the Router into an HttpServer plug and calls HttpServer.listen/1.
Blocks the calling process until the server exits.
Example:
BastionServer.start(router, Bastion.default_opts(4000))Start the Bastion server with a pre-built plug and options. Use this when you need to wrap the router in middleware (logger, static-file, etc.) before serving — the plug you supply is the single handler that every request flows through.
Example:
let pipeline = fn conn ->
Middleware.pipeline([Middleware.logger, static_plug, Router.to_plug(router)], conn)
BastionServer.start_plug(pipeline, Bastion.default_opts(4000))Wait for a server subprocess returned by spawn_n to exit.