Add missing proposals route
This commit is contained in:
parent
6a632238d5
commit
d4c809abed
21
proposals.go
21
proposals.go
|
@ -12,6 +12,27 @@ func init() {
|
|||
func(q Question, u *User, _ []byte) HTTPResponse {
|
||||
return formatApiResponse(q.GetProposals())
|
||||
}), loggedUser))
|
||||
router.POST("/api/questions/:qid/proposals", apiAuthHandler(questionAuthHandler(func(q Question, u *User, body []byte) HTTPResponse {
|
||||
var new Proposal
|
||||
if err := json.Unmarshal(body, &new); err != nil {
|
||||
return APIErrorResponse{err: err}
|
||||
}
|
||||
|
||||
return formatApiResponse(q.NewProposal(new.Label))
|
||||
}), adminRestricted))
|
||||
router.PUT("/api/questions/:qid/proposals/:pid", apiAuthHandler(proposalAuthHandler(func(current Proposal, u *User, body []byte) HTTPResponse {
|
||||
var new Proposal
|
||||
if err := json.Unmarshal(body, &new); err != nil {
|
||||
return APIErrorResponse{err: err}
|
||||
}
|
||||
|
||||
new.Id = current.Id
|
||||
return formatApiResponse(new.Update())
|
||||
}), adminRestricted))
|
||||
router.DELETE("/api/questions/:qid/proposals/:pid", apiAuthHandler(proposalAuthHandler(func(p Proposal, u *User, body []byte) HTTPResponse {
|
||||
return formatApiResponse(p.Delete())
|
||||
}), adminRestricted))
|
||||
|
||||
router.GET("/api/surveys/:sid/questions/:qid/proposals", apiAuthHandler(questionAuthHandler(
|
||||
func(q Question, u *User, _ []byte) HTTPResponse {
|
||||
return formatApiResponse(q.GetProposals())
|
||||
|
|
Reference in New Issue
Block a user