Created
May 25, 2015 23:16
-
-
Save MarkNijhof/3a74c6beaae40a799cb8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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