Combo.Router.Helpers (combo v0.10.1)
View SourceGenerates a module for route helpers and generic url helpers.
Route helpers exist to avoid hardcoding routes, if you wrote
<a href="/login"> and then changed your router, the link would point to a
page that no longer exist. By using router helpers, you can make sure it
always points to a valid URL in your router.
Generic url helpers exist for convenience.
Examples
defmodule MyApp.Web.Router do
use Combo.Router
# ...
endIt will generated a module named MyApp.Web.Router.Helpers, and following
functions are available.
Route helpers:
*_url/_*_path/_
Generic url helpers:
url/_path/_static_url/_static_path/_static_integrity/_
Forwarded routes
Forwarded routes are also resolved automatically. For example, you have a a forward path to an admin router in your main router:
defmodule MyApp.Web.Router do
# ...
forward "/admin", MyApp.Web.AdminRouter
end
defmodule MyApp.Web.AdminRouter do
# ...
get "/users", MyApp.Web.Admin.UserController
end
Summary
Functions
Generates the helper module for the given environment and routes.