// statement, _ := database.Prepare("CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY, username TEXT UNIQUE, password TEXT, wins INTEGER, losses INTEGER, draws INTEGER)")
// statement.Exec()
// // test query
// database.QueryRow("INSERT INTO users(username, password, wins) VALUES($1, $2, $3);",
// "user123", "qwerty", 0)
http.HandleFunc("/",hello)
http.HandleFunc("/",hello)
// Game processing endpoints
// Game processing endpoints
...
@@ -77,12 +59,7 @@ func main() {
...
@@ -77,12 +59,7 @@ func main() {
http.HandleFunc("/join",joinGame)
http.HandleFunc("/join",joinGame)
http.HandleFunc("/wait",checkJoinGame)
http.HandleFunc("/wait",checkJoinGame)
// User authentication endpoints
err:=http.ListenAndServe(":8080",nil)
http.HandleFunc("/create-account",createUser)
http.HandleFunc("/login",login)
http.HandleFunc("/leaderboard",leaderboard)
err=http.ListenAndServe(":8080",nil)
iferr!=nil{
iferr!=nil{
log.Println("could not start server")
log.Println("could not start server")
}
}
...
@@ -221,126 +198,6 @@ func checkJoinGame(w http.ResponseWriter, r *http.Request) {
...
@@ -221,126 +198,6 @@ func checkJoinGame(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w,p2)// send player2's name
fmt.Fprintf(w,p2)// send player2's name
}
}
// /************** User authentication and other ****************/