PhoenixAssetPipeline.Plug.Static (phoenix_asset_pipeline v2.0.2)

Copy Markdown View Source

A plug for serving pre-compiled assets and static files.

Options

  • :only - filters which requests to serve. This is useful to avoid file system access on every request when this plug is mounted at "/". For example, if only: ["images", "favicon.ico"] is specified, only files in the "images" directory and the "favicon.ico" file will be served by Plug.Static. Note that Plug.Static matches these filters against request uri and not against the filesystem. When requesting a file with name containing non-ascii or special characters, you should use urlencoded form. For example, you should write only: ["file%20name"] instead of only: ["file name"]. Defaults to nil (no filtering).

  • :only_matching - a relaxed version of :only that will serve any request as long as one of the given values matches the given path. For example, only_matching: ["images", "favicon"] will match any request that starts at "images" or "favicon", be it "/images/foo.png", "/images-high/foo.png", "/favicon.ico" or "/favicon-high.ico". Such matches are useful when serving digested files at the root. Defaults to nil (no filtering).

  • :content_types - controls custom MIME type mapping. It can be a map with filename as key and content type as value to override the default type for matching filenames. Alternatively, it can be false to opt out of setting the content type header. Defaults to manifest content types.