View Source Francis (Francis v0.1.5)
Module responsible for starting the Francis server and to wrap the Plug functionality
This module performs multiple tasks:
- Uses the Application module to start the Francis server
- Defines the Francis.Router which uses Francis.Plug.Router, :match and :dispatch
- Defines the macros get, post, put, delete, patch and ws to define routes for each operation
You can also set the following options:
- :bandit_opts - Options to be passed to Bandit
- :plugs - List of plugs to be used by Francis
Summary
Functions
Defines a DELETE route
Defines a GET route
Defines a PATCH route
Defines a POST route
Defines a PUT route
Defines an action for umatched routes and returns 404
Defines a WebSocket route that sends text type responses
Functions
Defines a DELETE route
Examples
defmodule Example.Router do
use Francis
delete "/hello", fn conn ->
"Hello World!"
end
end
Defines a GET route
Examples
defmodule Example.Router do
use Francis
get "/hello", fn conn ->
"Hello World!"
end
end
Defines a PATCH route
Examples
defmodule Example.Router do
use Francis
patch "/hello", fn conn ->
"Hello World!"
end
end
Defines a POST route
Examples
defmodule Example.Router do
use Francis
post "/hello", fn conn ->
"Hello World!"
end
end
Defines a PUT route
Examples
defmodule Example.Router do
use Francis
put "/hello", fn conn ->
"Hello World!"
end
end
Defines an action for umatched routes and returns 404
Defines a WebSocket route that sends text type responses
Examples
defmodule Example.Router do
use Francis
ws "/hello", fn _ ->
"Hello World!"
end
end