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

Function Votes

cloudsql/postgres/database-sql/cloudsql.go:211–220  ·  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

209// Votes handles HTTP requests to alternatively show the voting app or to save a
210// vote.
211func Votes(w http.ResponseWriter, r *http.Request) {
212 switch r.Method {
213 case http.MethodGet:
214 renderIndex(w, r, getDB())
215 case http.MethodPost:
216 saveVote(w, r, getDB())
217 default:
218 w.WriteHeader(http.StatusMethodNotAllowed)
219 }
220}
221
222// vote contains a single row from the votes table in the database. Each vote
223// 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