mirror of
https://github.com/aclindsa/moneygo.git
synced 2025-07-02 20:28:38 -04:00
Move to a consistent way of handling IDs in URLs
This commit is contained in:
@ -165,10 +165,7 @@ func PriceHandler(r *http.Request, context *Context) ResponseWriterWriter {
|
||||
|
||||
return ResponseWrapper{201, &price}
|
||||
} else if r.Method == "GET" {
|
||||
var priceid int64
|
||||
n, err := GetURLPieces(r.URL.Path, "/v1/prices/%d", &priceid)
|
||||
|
||||
if err != nil || n != 1 {
|
||||
if context.LastLevel() {
|
||||
//Return all prices
|
||||
var pl PriceList
|
||||
|
||||
@ -180,16 +177,21 @@ func PriceHandler(r *http.Request, context *Context) ResponseWriterWriter {
|
||||
|
||||
pl.Prices = prices
|
||||
return &pl
|
||||
} else {
|
||||
price, err := GetPrice(context.Tx, priceid, user.UserId)
|
||||
if err != nil {
|
||||
return NewError(3 /*Invalid Request*/)
|
||||
}
|
||||
|
||||
return price
|
||||
}
|
||||
|
||||
priceid, err := context.NextID()
|
||||
if err != nil {
|
||||
return NewError(3 /*Invalid Request*/)
|
||||
}
|
||||
|
||||
price, err := GetPrice(context.Tx, priceid, user.UserId)
|
||||
if err != nil {
|
||||
return NewError(3 /*Invalid Request*/)
|
||||
}
|
||||
|
||||
return price
|
||||
} else {
|
||||
priceid, err := GetURLID(r.URL.Path)
|
||||
priceid, err := context.NextID()
|
||||
if err != nil {
|
||||
return NewError(3 /*Invalid Request*/)
|
||||
}
|
||||
|
Reference in New Issue
Block a user