-
Notifications
You must be signed in to change notification settings - Fork 0
/
Controller.go
55 lines (38 loc) · 980 Bytes
/
Controller.go
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package main
import (
"github.com/gorilla/mux"
"net/http"
"encoding/json"
"log"
)
func main() {
router:=Router()
Rooms(*router)
Users(*router)
router.HandleFunc("/rooms", GetRoom).Methods("GET")
log.Print("Rooms API")
http.ListenAndServe(":1234", router);
}
func Router() *mux.Router {
router := mux.NewRouter()
return router
}
func Rooms(router mux.Router) mux.Router{
router.HandleFunc("/rooms", GetRoom).Methods("GET")
router.HandleFunc("/rooms", PutRoom).Methods("PUT")
router.HandleFunc("/rooms", DeleteRoom).Methods("DELETE")
return router
}
func Users(router mux.Router) {
router.HandleFunc("/users", GetUser).Methods("GET")
}
func GetUser(w http.ResponseWriter, r *http.Request) {
json.NewEncoder(w).Encode("Users")
}
func DeleteRoom(writer http.ResponseWriter, r *http.Request) {
}
func PutRoom(writer http.ResponseWriter, r *http.Request) {
}
func GetRoom(w http.ResponseWriter, r *http.Request) {
json.NewEncoder(w).Encode("Rooms")
}