elixir-maru / maru

Elixir RESTful Framework
https://maru.readme.io
BSD 3-Clause "New" or "Revised" License
1.32k stars 84 forks source link

Parsing Param Error #30

Closed rkulshrestha closed 8 years ago

rkulshrestha commented 8 years ago

Hi

I have been using 0.10.1 and keep getting this error whenever I put a params block into my code.

00:16:19.004 [error] #PID<0.291.0> running Testmaru.Api terminated
Server: localhost:8880 (http)
Request: POST /
** (exit) an exception was raised:
    ** (Maru.Exceptions.InvalidFormatter) Parsing Param Error: test
        (testmaru) lib/api.ex:1: anonymous fn/1 in Testmaru.Api.route/2
        (maru) lib/maru/runtime.ex:20: Maru.Runtime.parse_params/3
        (testmaru) lib/api.ex:1: Testmaru.Api.route/2
        (testmaru) lib/api.ex:1: Testmaru.Api.call/2
        (plug) lib/plug/adapters/cowboy/handler.ex:15: Plug.Adapters.Cowboy.Handler.upgrade/4
        (cowboy) src/cowboy_protocol.erl:442: :cowboy_protocol.execute/

The Module is as follows:


defmodule Testmaru.Api do
  use Maru.Router

  params do
   requires :test, type: String
  end
  post "/" do
    conn |> text("Hello")
  end

end

Have you seen this issue ??

rkulshrestha commented 8 years ago

FYI, rolling back to an older version fixes this issue for me

falood commented 8 years ago

There're some upgrade instructions here. It seems that you should add your own Plug.Parsers like this:

before do
  plug Plug.Parsers,
    pass: ["*/*"],
    json_decoder: Poison,
    parsers: [:urlencoded, :json, :multipart]
end
rkulshrestha commented 8 years ago

thanks. Apologies, my bad! did not read the upgrade instructions.

falood commented 8 years ago

May be I didn't make it easy to find. I have add this link to CHANGELOG.md.