예제 #1
0
func greeting(w http.ResponseWriter, r *http.Request) {
	params := webapi.Params(r)
	name := params["name"].(string)
	jsonapi.SetHeader(w)
	p, _ := json.Marshal(map[string]string{"result": "hello, " + name + "!"})
	w.Write(p)
}
예제 #2
0
func add(w http.ResponseWriter, r *http.Request) {
	params := webapi.Params(r)["json"].(*struct{ X, Y int })
	jsonapi.SetHeader(w)
	p, _ := json.Marshal(map[string]int{"result": params.X + params.Y})
	w.Write(p)
}