forked from HackIllinois/api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
checkin.go
67 lines (58 loc) · 2.17 KB
/
checkin.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
56
57
58
59
60
61
62
63
64
65
66
67
package services
import (
"github.com/HackIllinois/api/gateway/config"
"github.com/HackIllinois/api/gateway/middleware"
"github.com/HackIllinois/api/gateway/models"
"github.com/arbor-dev/arbor"
"github.com/justinas/alice"
"net/http"
)
var CheckinURL = config.CHECKIN_SERVICE
const CheckinFormat string = "JSON"
var CheckinRoutes = arbor.RouteCollection{
arbor.Route{
"GetCurrentCheckinInfo",
"GET",
"/checkin/",
alice.New(middleware.AuthMiddleware([]models.Role{models.AttendeeRole}), middleware.IdentificationMiddleware).ThenFunc(GetCurrentCheckinInfo).ServeHTTP,
},
arbor.Route{
"CreateCurrentCheckinInfo",
"POST",
"/checkin/",
alice.New(middleware.AuthMiddleware([]models.Role{models.AdminRole, models.StaffRole}), middleware.IdentificationMiddleware).ThenFunc(CreateCurrentCheckinInfo).ServeHTTP,
},
arbor.Route{
"UpdateCurrentCheckinInfo",
"PUT",
"/checkin/",
alice.New(middleware.AuthMiddleware([]models.Role{models.AdminRole, models.StaffRole}), middleware.IdentificationMiddleware).ThenFunc(UpdateCurrentCheckinInfo).ServeHTTP,
},
arbor.Route{
"GetAllCheckedInUsers",
"GET",
"/checkin/list/",
alice.New(middleware.AuthMiddleware([]models.Role{models.AdminRole, models.StaffRole}), middleware.IdentificationMiddleware).ThenFunc(GetAllCheckedInUsers).ServeHTTP,
},
arbor.Route{
"GetCheckinInfo",
"GET",
"/checkin/{id}/",
alice.New(middleware.AuthMiddleware([]models.Role{models.AdminRole, models.StaffRole}), middleware.IdentificationMiddleware).ThenFunc(GetCheckinInfo).ServeHTTP,
},
}
func GetCurrentCheckinInfo(w http.ResponseWriter, r *http.Request) {
arbor.GET(w, CheckinURL+r.URL.String(), CheckinFormat, "", r)
}
func CreateCurrentCheckinInfo(w http.ResponseWriter, r *http.Request) {
arbor.POST(w, CheckinURL+r.URL.String(), CheckinFormat, "", r)
}
func UpdateCurrentCheckinInfo(w http.ResponseWriter, r *http.Request) {
arbor.PUT(w, CheckinURL+r.URL.String(), CheckinFormat, "", r)
}
func GetCheckinInfo(w http.ResponseWriter, r *http.Request) {
arbor.GET(w, CheckinURL+r.URL.String(), CheckinFormat, "", r)
}
func GetAllCheckedInUsers(w http.ResponseWriter, r *http.Request) {
arbor.GET(w, CheckinURL+r.URL.String(), CheckinFormat, "", r)
}