mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
using common for all json reading.
This commit is contained in:
@@ -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:"
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user