RevisionPlateEx v0.4.1 RevisionPlateEx.Hello View Source
Define RevisionPlateEx Hello.
This module defines functions to generate %Plug.Conn{} which have revision plate. To use this feature, you should set as the following example.
Example with Plug
defmodule MyApp.Hello do
import Plug.Conn
def sample_revision(conn), do: RevisionPlateEx.Hello.revision conn
end
Then MyApp.Hello.sample_revision/1 return 200 as status code and binary read from REVISION file which exists on root path as default. Return 404 and not found message if REVISION file doesn’t exist.
Link to this section Summary
Functions
This function can use with Phoenix like the following. In this case, when anyone access to /hello/revision with GET method, then return revision with 200 statuscode or not found message with 404
Link to this section Types
conn() :: %Plug.Conn{
adapter: term(),
assigns: term(),
before_send: term(),
body_params: term(),
cookies: term(),
halted: term(),
host: term(),
method: term(),
owner: term(),
params: term(),
path_info: term(),
path_params: term(),
port: term(),
private: term(),
query_params: term(),
query_string: term(),
remote_ip: term(),
req_cookies: term(),
req_headers: term(),
request_path: term(),
resp_body: term(),
resp_cookies: term(),
resp_headers: term(),
scheme: term(),
script_name: term(),
secret_key_base: term(),
state: term(),
status: term()
}
Link to this section Functions
This function can use with Phoenix like the following. In this case, when anyone access to /hello/revision with GET method, then return revision with 200 statuscode or not found message with 404.
Example in web/router.ex
defmodule MyApp.Router do
use MyApp.Web, :router
...
scope "/", MyApp do
get "/hello/revision", HelloController, :revision
end
end
Example in web/controllers/hello_controller.ex
defmodule MyApp.Hello do
use MyApp.Web, :controller
def revision(conn, _opt), do: RevisionPlateEx.Hello.revision conn
end