/
userRoute.go
46 lines (42 loc) · 1.18 KB
/
userRoute.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
package user
import (
"net/http"
"github.com/azukaar/cosmos-server/src/utils"
)
func UsersIdRoute(w http.ResponseWriter, req *http.Request) {
if(req.Method == "DELETE") {
UserDelete(w, req)
} else if (req.Method == "GET") {
UserGet(w, req)
} else if (req.Method == "PATCH") {
UserEdit(w, req)
} else {
utils.Error("UserRoute: Method not allowed" + req.Method, nil)
utils.HTTPError(w, "Method not allowed", http.StatusMethodNotAllowed, "HTTP001")
return
}
}
func UsersRoute(w http.ResponseWriter, req *http.Request) {
if (req.Method == "POST") {
UserCreate(w, req)
} else if (req.Method == "GET") {
UserList(w, req)
} else {
utils.Error("UserRoute: Method not allowed" + req.Method, nil)
utils.HTTPError(w, "Method not allowed", http.StatusMethodNotAllowed, "HTTP001")
return
}
}
func API2FA(w http.ResponseWriter, req *http.Request) {
if(req.Method == "POST") {
Check2FA(w, req)
} else if (req.Method == "GET") {
New2FA(w, req)
} else if (req.Method == "DELETE") {
Delete2FA(w, req)
} else {
utils.Error("API2FARoute: Method not allowed" + req.Method, nil)
utils.HTTPError(w, "Method not allowed", http.StatusMethodNotAllowed, "HTTP001")
return
}
}