Skip to content

Instantly share code, notes, and snippets.

@MarkNijhof
Created May 25, 2015 23:16
Show Gist options
  • Save MarkNijhof/3a74c6beaae40a799cb8 to your computer and use it in GitHub Desktop.
Save MarkNijhof/3a74c6beaae40a799cb8 to your computer and use it in GitHub Desktop.
defmodule Drive.ApiRouter do
require Logger
require Path
use Plug.Router
import Plug.Conn
plug Plug.Logger
plug Plug.Head
plug :match
plug :dispatch
plug Plug.Parsers,
parsers: [:json],
pass: ["*/*"],
json_decoder: Poison
post "/" do
# This route is being forwarded to from the base router
# When I post JSON to this route it seems that it is not automatically parsed
# I can get it via:
# {:ok, body, conn} = Plug.Conn.read_body(conn)
# %{<<"name">> => folderName} = Poison.Parser.parse!(body)
end
match _ do
send_resp(conn, 404, "not found")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment