Exemplo n.º 1
0
func retreiveOrder(w http.ResponseWriter, r *http.Request) errors.Http {
	queryString := r.URL.Query()
	var o models.Order
	decoder := decoder.NewDecoder()

	if err := decoder.DecodeURLValues(&o, queryString); err != nil {
		return errors.BadRequest(err.Error())
	}

	orders, err := o.Retreive(db)
	if err != nil {
		return errors.InternalServerError(err.Error())
	}

	if len(orders) == 0 {
		return errors.NotFound("record not found")
	}

	rend.JSON(w, http.StatusOK, orders)
	return nil
}
Exemplo n.º 2
0
Arquivo: utils.go Projeto: asvins/core
func BuildStructFromQueryString(dst interface{}, queryString url.Values) error {
	decoder := decoder.NewDecoder()
	return decoder.DecodeURLValues(dst, queryString)
}