RephiWeb.Plugs.FrontendAppPlug (Rephi v0.1.0)

View Source

Plug for serving frontend applications with CSRF token injection.

This plug serves static HTML files from priv/static/apps/ and injects the CSRF token into the HTML before sending it to the client.

Usage

# In router.ex
forward "/app/example", RephiWeb.Plugs.FrontendAppPlug, app: "example"

The plug will:

  1. Serve the index.html from priv/static/apps/{app_name}/
  2. Inject CSRF token into a meta tag or script tag
  3. Serve other static assets without modification

Summary

Functions

call(conn, map)

init(opts)