コード例 #1
0
ファイル: backend.go プロジェクト: section14/go_polymer_comm
func ProductGetHandler(w http.ResponseWriter, r *http.Request) {
	//product id
	vars := mux.Vars(r)
	strId := vars["id"]

	id, err := strconv.ParseInt(strId, 10, 64)

	if err != nil {
		log.Println(err)
	}

	productController := controller.Product{}
	product, err := productController.GetProduct(r, id)

	if err != nil {
		log.Println(err)
	} else {
		jsonRes, _ := json.Marshal(product)
		fmt.Fprint(w, string(jsonRes))
	}
}