mirror of
https://github.com/aclindsa/moneygo.git
synced 2025-07-03 12:48:38 -04:00
API: Move prices under securities
For example, instead of GETting /prices/5 to query a price with ID 5, you now must GET /securities/2/prices/5 (assuming price 5's SecurityId is 2)
This commit is contained in:
@ -253,6 +253,17 @@ func SecurityHandler(r *http.Request, context *Context) ResponseWriterWriter {
|
||||
}
|
||||
|
||||
if r.Method == "POST" {
|
||||
if !context.LastLevel() {
|
||||
securityid, err := context.NextID()
|
||||
if err != nil {
|
||||
return NewError(3 /*Invalid Request*/)
|
||||
}
|
||||
if context.NextLevel() != "prices" {
|
||||
return NewError(3 /*Invalid Request*/)
|
||||
}
|
||||
return PriceHandler(r, context, user, securityid)
|
||||
}
|
||||
|
||||
var security Security
|
||||
if err := ReadJSON(r, &security); err != nil {
|
||||
return NewError(3 /*Invalid Request*/)
|
||||
@ -285,6 +296,14 @@ func SecurityHandler(r *http.Request, context *Context) ResponseWriterWriter {
|
||||
if err != nil {
|
||||
return NewError(3 /*Invalid Request*/)
|
||||
}
|
||||
|
||||
if !context.LastLevel() {
|
||||
if context.NextLevel() != "prices" {
|
||||
return NewError(3 /*Invalid Request*/)
|
||||
}
|
||||
return PriceHandler(r, context, user, securityid)
|
||||
}
|
||||
|
||||
security, err := GetSecurity(context.Tx, securityid, user.UserId)
|
||||
if err != nil {
|
||||
return NewError(3 /*Invalid Request*/)
|
||||
@ -297,6 +316,13 @@ func SecurityHandler(r *http.Request, context *Context) ResponseWriterWriter {
|
||||
if err != nil {
|
||||
return NewError(3 /*Invalid Request*/)
|
||||
}
|
||||
if !context.LastLevel() {
|
||||
if context.NextLevel() != "prices" {
|
||||
return NewError(3 /*Invalid Request*/)
|
||||
}
|
||||
return PriceHandler(r, context, user, securityid)
|
||||
}
|
||||
|
||||
if r.Method == "PUT" {
|
||||
var security Security
|
||||
if err := ReadJSON(r, &security); err != nil || security.SecurityId != securityid {
|
||||
|
Reference in New Issue
Block a user