class

Analyzer::Erlang::Elli

Inherits Analyzer < FileHelper < Reference < Object

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.

Constants

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/

Class methods

tech_name
Source

Instance methods

analyze
Source
tech

Instance-side view of the same declaration. The per-file rescues live on this base class, which has no way to name the analyzer that is running inside them, so a skipped file could not be attributed to a tech. Deriving it from analyzer_for keeps the name written exactly once.

Source