Runlight.Plug.Links (runlight v0.3.2)

Copy Markdown View Source

Short links on the app's own domain: forward the instance's link path (default "/go") here, and /go/{slug} redirects to the link's destination, with the click recorded. A request on a link domain is answered as that domain's links first, so /go/{slug} there is a 404.

forward "/go", Runlight.Plug.Links

A slug no link has is the app's to answer. Forwarded from a Phoenix router, that raises Phoenix.Router.NoRouteError, so the app's own 404 page shows; from a plain Plug.Router, which has no such page to hand it to, it is answered with a 404.

Anywhere else, such as an endpoint or a pipeline ahead of the routes, it is middleware: it answers link domains and a GET for /go/{slug} when the link exists, and every other request, an unknown slug too, carries on to the app untouched.

plug Runlight.Plug.Links