Revel doesn't parse JSON parameter when the content type is "application/json".
How to enforce this ?
Example :
http://localhost:9000/foundations
in POST call Foundations.Create
function.
Into this function I use fmt.Println("Params :", c.Params)
to check parameters
Ruby POST JSON data
#!/usr/bin/env ruby
require "rubygems"
require "json"
require "net/https"
uri = URI.parse("http://localhost:9000/foundations")
http = Net::HTTP.new(uri.host, uri.port)
header = { "Content-Type" => "application/json" }
req = Net::HTTP::Post.new(uri.path, header)
req.body = {
"data" => "mysurface"
}.to_json()
res = http.start { |http| http.request(req) }
The debug print is
Params : &{map[] map[] map[] map[] map[] map[] []}
And when I use none "application/json" like :
curl -F 'data=mysurface' http://127.0.0.1:9000/foundations
The print is :
Params : &{map[data:[mysurface]] map[] map[] map[] map[data:[mysurface]] map[] []}