Use the skills that you have learned so far in this workshop to fulfill the web services requirements.
- HTTP POST to create a vote submission
- HTTP GET to retrieve voting results
Using the same model of a Vote, your web service should:
// Vote represents one voter casting one vote in one poll.
// A single voter can only vote once for any given poll.
type Vote struct {
Voter string `json:"voter"`
Poll string `json:"topic"`
Choice string `json:"choice"`
}
For example, given the following votes:
Voter | Poll | Choice |
---|---|---|
Alice | 1 | For |
Bob | 1 | For |
Carol | 1 | Against |
Alice | 2 | Against |
Eve | 2 | For |
A request to your web service for poll 1 could return:
{
"results": [
{
"poll": "1",
"votes": [
{"choice": "For", "votes": 2},
{"choice": "Against", "votes": 1}
]
}
]
}
Do not get stuck on the particular shape of the JSON, ordering, etc. - the goal is to fulfill the requirement of returning a sum of the votes for each choice in a given poll.