using common for all json reading.

This commit is contained in:
Travis
2013-01-16 00:52:06 -08:00
parent c11da41fea
commit 435642ef01
2 changed files with 3 additions and 5 deletions

View File

@@ -17,7 +17,7 @@ code_name = @config[:iron][:code_name] || "sinatra"
response = rest.post(
# "http://localhost:8080/",
"http://router.irondns.info/?project_id=#{project_id}&token=#{token}&code_name=#{code_name}",
headers: {"Iron-Router"=>"register"},
headers: {"Iron-Router"=>"register", "Content-Type"=>"application/json"},
body: {"host"=>host_name, "code"=>code_name}
)
puts "response body:"

View File

@@ -214,10 +214,8 @@ func AddWorker(w http.ResponseWriter, req *http.Request) {
} else {
r2 := Route2{}
decoder := json.NewDecoder(req.Body)
err := decoder.Decode(&r2)
if err != nil {
common.SendError(w, 400, fmt.Sprintln("Bad json:", err))
if !common.ReadJSON(w, req, &r2) {
return
}
// todo: do we need to close body?
fmt.Println("DECODED:", r2)