MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/golang-samples / Votes

Function Votes

cloudsql/sqlserver/database-sql/cloudsql.go:199–208  ·  view source on GitHub ↗

Votes handles HTTP requests to alternatively show the voting app or to save a vote.

(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

197// Votes handles HTTP requests to alternatively show the voting app or to save a
198// vote.
199func Votes(w http.ResponseWriter, r *http.Request) {
200 switch r.Method {
201 case http.MethodGet:
202 renderIndex(w, r, getDB())
203 case http.MethodPost:
204 saveVote(w, r, getDB())
205 default:
206 w.WriteHeader(http.StatusMethodNotAllowed)
207 }
208}
209
210// vote contains a single row from the votes table in the database. Each vote
211// includes a candidate ("TABS" or "SPACES") and a timestamp.

Callers 2

testGetVotesFunction · 0.70
testCastVoteFunction · 0.70

Calls 3

renderIndexFunction · 0.70
getDBFunction · 0.70
saveVoteFunction · 0.70

Tested by 2

testGetVotesFunction · 0.56
testCastVoteFunction · 0.56