forked from HackIllinois/api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rsvp.go
57 lines (49 loc) · 1.7 KB
/
rsvp.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
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 RsvpURL = config.RSVP_SERVICE
const RsvpFormat string = "JSON"
var RsvpRoutes = arbor.RouteCollection{
arbor.Route{
"GetCurrentRsvpInfo",
"GET",
"/rsvp/",
alice.New(middleware.AuthMiddleware([]models.Role{models.ApplicantRole}), middleware.IdentificationMiddleware).ThenFunc(GetCurrentRsvpInfo).ServeHTTP,
},
arbor.Route{
"CreateCurrentRsvpInfo",
"POST",
"/rsvp/",
alice.New(middleware.AuthMiddleware([]models.Role{models.ApplicantRole}), middleware.IdentificationMiddleware).ThenFunc(CreateCurrentRsvpInfo).ServeHTTP,
},
arbor.Route{
"UpdateCurrentRsvpInfo",
"PUT",
"/rsvp/",
alice.New(middleware.AuthMiddleware([]models.Role{models.ApplicantRole}), middleware.IdentificationMiddleware).ThenFunc(UpdateCurrentRsvpInfo).ServeHTTP,
},
arbor.Route{
"GetRsvpInfo",
"GET",
"/rsvp/{id}/",
alice.New(middleware.AuthMiddleware([]models.Role{models.AdminRole, models.StaffRole}), middleware.IdentificationMiddleware).ThenFunc(GetRsvpInfo).ServeHTTP,
},
}
func GetCurrentRsvpInfo(w http.ResponseWriter, r *http.Request) {
arbor.GET(w, RsvpURL+r.URL.String(), RsvpFormat, "", r)
}
func CreateCurrentRsvpInfo(w http.ResponseWriter, r *http.Request) {
arbor.POST(w, RsvpURL+r.URL.String(), RsvpFormat, "", r)
}
func UpdateCurrentRsvpInfo(w http.ResponseWriter, r *http.Request) {
arbor.PUT(w, RsvpURL+r.URL.String(), RsvpFormat, "", r)
}
func GetRsvpInfo(w http.ResponseWriter, r *http.Request) {
arbor.GET(w, RsvpURL+r.URL.String(), RsvpFormat, "", r)
}