Add some TODO and add 500 error responses in openapi.yml. Also write the endpoint for election results
This commit is contained in:
@ -133,10 +133,10 @@ func (app *application) createVotes(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
election, err := app.elections.GetById(request.ElectionId)
|
||||
election, err := app.elections.GetById(request.ElectionId) // get from path instead of from the JSON
|
||||
if err != nil {
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
app.unprocessableEntityErrorSingle(w, fmt.Errorf("election with id %v doesn't exist", request.ElectionId))
|
||||
app.unprocessableEntityErrorSingle(w, fmt.Errorf("election with id %v doesn't exist", request.ElectionId)) // TODO: return 404
|
||||
return
|
||||
}
|
||||
app.serverError(w, r, err)
|
||||
|
Reference in New Issue
Block a user