trot
trot copied to clipboard
Documentation on how to fetch request body data
Documentation on the intended way on how to fetch the request body data for PUT/POST/... requests is missing.
put "/" do
IO.puts(inspect(conn.body_params))
""
end
# Prints:
# %Plug.Conn.Unfetched{aspect: :body_params}
I found out in the meantime - you're supposed to do this through the config:
eg.
config :trot, :pre_routing, [
# other plugs...
"Elixir.Plug.Parsers": [parsers: [:json], json_decoder: Poison],
]