Spaceboy.Router (Spaceboy v0.1.1) View Source

Router implementation for Spaceboy server.

Router is technically a Spaceboy.Middleware but it is so havily 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.

Link to this section Summary

Functions

Adds redirect

Adds route for URL

Render static files route

Link to this section Functions

Link to this macro

redirect(from, to)

View Source (macro)

Adds redirect

Link to this macro

route(pattern, module, fun)

View Source (macro)

Adds route for URL

Link to this macro

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

View Source (macro)

Render static files route

Options

  • ls_dir?: boolean() - if true (default) directories will list it's files
  • mime: :guess | String.t() - what MIME type to use for files. Can be :guess to use MIME library to guess mime type of files. Or can be specific MIME type e.g. "text/gemini" (default)