Seely.Router (Seely v0.1.0) View Source

Functions to find routes in a user-defined router. (See Seely.DefaultRouter).

Link to this section Summary

Functions

Find a route for a given parsed command. A parsed command, as returned from parse/2 has the form

Create a new router (which is nothing than a simple Keyword list) with initially one key only, the :module where the actual router is defined.

Parse the command the user entered.

Link to this section Functions

Link to this function

find_route(parsed_command, routes)

View Source

Find a route for a given parsed command. A parsed command, as returned from parse/2 has the form

{parsed_options, parameters, invalid_options}

# Example: {[upper: true, trim: true], ["echo", " string "], []}

The function either returns a found route in the form

{command, controller, :function}

or, if no function could be found, it returns a route to the Seely.EchoController's :error-function.

Create a new router (which is nothing than a simple Keyword list) with initially one key only, the :module where the actual router is defined.

Keys: routes and parse_opts will be added later.

Parse the command the user entered.

The options and routes are fetched from the given router (See Seely.DefaultRouter). The command gets parsed by Seely.Parser and returns a route ({command,controller,:function}) for this command if one could be found. Otherwise it returns {:error, "No route found"}.