예제 #1
0
func GetLocationById(w http.ResponseWriter, r *http.Request, enc encoding.Encoder, params martini.Params) string {
	str_id := params["id"]
	if str_id == "" {
		apierror.GenerateError("You must supply a location identification number.", errors.New("No id."), w, r)
	}
	id, err := strconv.Atoi(str_id)
	if err != nil {
		apierror.GenerateError("You must supply a location identification number.", err, w, r)
	}
	var l customer.CustomerLocation
	l.Id = id
	// loc, err := customer.GetLocationById(id)
	err = l.Get()
	if err != nil {
		apierror.GenerateError("Error retrieving locations.", err, w, r)
	}

	return encoding.Must(enc.Encode(l))
}