Skip to content

Instantly share code, notes, and snippets.

@myobie

myobie/router.ex

Last active Apr 15, 2021
Embed
What would you like to do?
A pipeline for proxying large file uploads
defmodule AppWeb.Router do
use AppWeb, :router
pipeline :browser do
plug Plug.Parsers,
parsers: [:urlencoded, :multipart, :json],
pass: ["*/*"],
json_decoder: Phoenix.json_library()
plug Plug.MethodOverride
plug Plug.Head
plug :accepts, ["html"]
plug :fetch_session
plug :fetch_flash
plug :protect_from_forgery
plug :put_secure_browser_headers
end
pipeline :api do
plug Plug.Parsers,
parsers: [:multipart, :json],
pass: ["*/*"],
json_decoder: Phoenix.json_library()
plug Plug.Head
plug :accepts, ["json"]
end
pipeline :binary do
# NOTE: It is important that this pipeline never include
# Plug.Parsers or it will spool every file to disk
plug :accepts, ["special-binary-v1"]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment