-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.go
More file actions
35 lines (27 loc) · 908 Bytes
/
Copy pathserver.go
File metadata and controls
35 lines (27 loc) · 908 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package main
import (
//"fmt"
"github.com/gorilla/mux"
"github.com/telecoda/go-man-app/controllers"
"net/http"
)
var r *mux.Router
func init() {
//fmt.Println("go-man server starting1")
r = mux.NewRouter()
r.HandleFunc("/", controllers.RootHandler).Methods("GET")
//fmt.Println("go-man server starting2")
// list games
r.HandleFunc("/games", controllers.GameList).Methods("GET")
// create new game
r.HandleFunc("/games", controllers.GameCreate).Methods("POST")
// get game by id
r.HandleFunc("/games/{gameId}", controllers.GameById).Methods("GET")
// add new player to game
r.HandleFunc("/games/{gameId}/players", controllers.AddPlayer).Methods("POST")
// update player
r.HandleFunc("/games/{gameId}/players/{playerId}", controllers.ConcurrentUpdatePlayer).Methods("PUT")
// options
r.HandleFunc("/{path:.*}", controllers.OptionsHandler).Methods("OPTIONS")
http.Handle("/", r)
}