Onward (onward v0.0.2)

A plug module for proxying paths to another location using a macro.

Example Usage

defmodule MyRouter do
  use Plug.Router
  use Onward

  plug :match
  plug :dispatch

  proxy "/path", to: "http://localhost:4000"

  match _ do
    send_resp(conn, 404, "Not Found")
  end
end

Summary

Functions

Defines a proxy route that forwards requests from the specified path to the given destination.

Functions

Link to this macro

proxy(path, opts)

(macro)

Defines a proxy route that forwards requests from the specified path to the given destination.

Parameters

  • path: The path to proxy from.
  • opts: Keyword list of options. Expected key is :to with the destination URL.

Example

proxy "/path", to: "http://localhost:4000"