Plug.Static

A plug for serving static assets.

It expects two options on initialization:

The preferred form is to use :from with an atom, since it will make your application independent from the starting directory.

If a static asset cannot be found, it simply forwards the connection to the rest of the stack.

Options

Examples

This filter can be mounted in a Plug.Builder as follow:

defmodule MyPlug do
  use Plug.Builder

  plug Plug.Static, at: "/public", from: :my_app
  plug :not_found

  def not_found(conn, _) do
    Plug.Conn.send_resp(conn, 404, "not found")
  end
end

Summary

call(conn, arg2)
init(opts)

Functions

call(conn, arg2)
init(opts)