Monitorex.Assets (monitorex v0.8.0)

Copy Markdown

Plug for serving Monitorex dashboard static assets (CSS and JS).

Reads the asset files at compile time and serves them with far-future cache headers.

Usage

In your router:

get "/dashboard-assets/*path", Monitorex.Assets, :call

Or in a plug pipeline:

plug Monitorex.Assets, at: "/dashboard-assets"

Summary

Functions

Plug call callback. Serves the requested asset file or returns 404.

Returns the MD5 hex digest of the CSS file contents.

Plug init callback.

Returns the MD5 hex digest of the JS file contents.

Functions

call(conn, opts)

Plug call callback. Serves the requested asset file or returns 404.

The filename is matched by the trailing path segment, so assets are served correctly when the dashboard is mounted under any path prefix — whether the prefix comes from the endpoint mount (conn.script_name), a router scope, a reverse proxy, or a custom assets_path. The router route pattern (e.g. get "/dashboard-assets/*path") guarantees the request reached this plug only under the configured asset mount path.

css_hash()

Returns the MD5 hex digest of the CSS file contents.

init(opts)

Plug init callback.

Options

  • :at — accepted for backwards compatibility (default: "/dashboard-assets"). The request path is matched by its trailing filename segment, so the option no longer affects serving.

js_hash()

Returns the MD5 hex digest of the JS file contents.