View Source Spaceboy.Router (Spaceboy v0.3.2)

Router implementation for Spaceboy server.

Router is technically a Spaceboy.Middleware but it is so heavily customized that you would not recognize it. But of course you don't have to use this helper module and implement it from scratch as Spaceboy.Middleware.

Spaceboy.Router is usually last middleware in your Spaceboy.Server but it is not requirement.

Summary

Functions

Adds redirect

Render /robots.txt file

Adds route for URL

Render static files route

Functions

redirect(from, to)

(macro)
@spec redirect(from :: String.t(), to :: String.t()) :: Macro.t()

Adds redirect

robots(paths)

(macro)

Render /robots.txt file

Options

List of paths which should be disallowed for robots to crawl

route(pattern, module, fun)

(macro)
@spec route(pattern :: String.t(), module :: module(), fun :: atom()) :: Macro.t()

Adds route for URL

static(prefix, root, opts \\ [])

(macro)
@spec static(prefix :: String.t(), root :: Path.t(), opts :: Keyword.t()) :: Macro.t()

Render static files route

Options

See Spaceboy.Static.render/2 for options (:root and :prefix are populated automatically ;) )