Skip to content

Commit

Permalink
Merge pull request #2 from dxe/jake/add-tally-endpoint
Browse files Browse the repository at this point in the history
fix url param
  • Loading branch information
jakehobbs authored Jun 21, 2024
2 parents 07a956e + 6ae072f commit 5611bff
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions service/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (

"github.com/dxe/helptheducks.com/service/config"
"github.com/dxe/helptheducks.com/service/model"
"github.com/go-chi/chi/v5"
)

type CreateMessageInput struct {
Expand Down Expand Up @@ -100,7 +99,12 @@ type GetTallyResp struct {
}

func getTallyHandler(w http.ResponseWriter, r *http.Request) {
campaign := chi.URLParam(r, "campaign")
queryParams := r.URL.Query()
campaign := queryParams.Get("campaign")
if (campaign == "") {
http.Error(w, "missing campaign", http.StatusBadRequest)
return
}

tally, err := model.GetTally(db, campaign)
if err != nil {
Expand Down

0 comments on commit 5611bff

Please sign in to comment.