gofmt
This commit is contained in:
parent
e1e7c16193
commit
b8e0bd64f6
14
handlers.go
14
handlers.go
@ -105,13 +105,13 @@ func attempt(w http.ResponseWriter, req *http.Request) {
|
|||||||
|
|
||||||
session, _ := store.Get(req, "Score")
|
session, _ := store.Get(req, "Score")
|
||||||
score := getScore(session)
|
score := getScore(session)
|
||||||
if result {
|
if result {
|
||||||
score += 1
|
score += 1
|
||||||
} else {
|
} else {
|
||||||
score -= 1
|
score -= 1
|
||||||
}
|
}
|
||||||
session.Values["Score"] = score
|
session.Values["Score"] = score
|
||||||
session.Save(req, w)
|
session.Save(req, w)
|
||||||
|
|
||||||
b, err := json.Marshal(solution{result, score})
|
b, err := json.Marshal(solution{result, score})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
10
main.go
10
main.go
@ -4,9 +4,9 @@ import (
|
|||||||
"flag"
|
"flag"
|
||||||
"github.com/gorilla/sessions"
|
"github.com/gorilla/sessions"
|
||||||
"log"
|
"log"
|
||||||
|
"math/rand"
|
||||||
"net/http"
|
"net/http"
|
||||||
"math/rand"
|
"time"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const MAX = 12
|
const MAX = 12
|
||||||
@ -17,12 +17,12 @@ var static_files = flag.String("static", "./static", "location of static files")
|
|||||||
var store = sessions.NewCookieStore([]byte("hello world"))
|
var store = sessions.NewCookieStore([]byte("hello world"))
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
rand.Seed( time.Now().UTC().UnixNano())
|
rand.Seed(time.Now().UTC().UnixNano())
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
http.Handle("/",
|
http.Handle("/",
|
||||||
http.FileServer(http.Dir(*static_files)))
|
http.FileServer(http.Dir(*static_files)))
|
||||||
http.Handle("/api/v0/problem/", JsonHandler(problem))
|
http.Handle("/api/v0/problem/", JsonHandler(problem))
|
||||||
http.Handle("/api/v0/attempt/", JsonHandler(attempt))
|
http.Handle("/api/v0/attempt/", JsonHandler(attempt))
|
||||||
if err := http.ListenAndServe(*addr, nil); err != nil {
|
if err := http.ListenAndServe(*addr, nil); err != nil {
|
||||||
log.Fatal("ListenAndServe:", err)
|
log.Fatal("ListenAndServe:", err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user