class
Analyzer::Erlang::Elli
- Analyzer::Erlang::Elli
- Analyzer
- Reference
- Object
Overview
Elli has no router at all — an elli_handler callback module routes
by pattern-matching the method and the split path in its handle/3
function head:
handle(Req, _Args) ->
handle(Req#req.method, elli_request:path(Req), Req).
handle('GET', [<<"hello">>, <<"world">>], _Req) ->
{ok, [], <<"Hello World!">>};
handle('POST', [<<"users">>], Req) ->
...
Unlike Cowboy the verb is right there in the clause head, so no cross-module lookup is needed.
Defined in:
analyzer/analyzers/erlang/elli.crConstant Summary
-
BINARY_SEGMENT =
/\A<<\s*"([^"]*)"\s*>>\z/ -
BODY_REGEX =
/elli_request:(?:body|post_args)\s*\(/ -
CLAUSE_REGEX =
/^\s*handle\s*\(\s*(?:'([A-Za-z]+)'|<<\s*"([A-Za-z]+)"\s*>>|([A-Z_][A-Za-z0-9_]*))\s*,\s*\[([^\]]*)\]/ -
The 2-arity
handle(Req, _Args)dispatcher carries no path, so the head must bind a list in slot 2 to count as a route. -
GET_ARG_REGEX =
/elli_request:get_arg(?:_decoded)?\s*\(\s*<<\s*"([^"]+)"\s*>>/ -
HEADER_REGEX =
/elli_request:get_header\s*\(\s*<<\s*"([^"]+)"\s*>>/ -
HTTP_VERBS =
Set {"GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"} -
NEXT_CLAUSE =
/^\s*handle\s*\(/ -
POST_ARG_REGEX =
/elli_request:post_arg(?:_decoded)?\s*\(\s*<<\s*"([^"]+)"\s*>>/ -
VARIABLE =
/\A[A-Z][A-Za-z0-9_]*\z/