-
Notifications
You must be signed in to change notification settings - Fork 0
/
routers.go
47 lines (37 loc) · 3.02 KB
/
routers.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
package notary
import (
"github.com/NTRYPlatform/ntry-backend/ws"
"github.com/gorilla/mux"
)
func (n *Notary) muxServer() (router *mux.Router) {
handler := &Handler{}
handler.ec = n.ethClient
handler.db = n.db
handler.logger = n.logger
router = mux.NewRouter()
router.Handle("/", Adapt(handler, Index(handler), Logging(handler))).Methods("GET")
router.Handle("/sign-up", Adapt(handler, CreateUser(handler, n.email), Logging(handler))).Methods("POST")
router.Handle("/sign-in", Adapt(handler, LoginHandler(handler, n.conf), Logging(handler))).Methods("POST")
router.Handle("/send-invitation", Adapt(handler, NotImplemented(handler), Logging(handler))).Methods("GET")
//TODO: specify .Headers()
router.Handle("/user/update", Adapt(handler, UpdateUserInfo(handler), ValidateTokenMiddleware(handler, n.conf), Logging(handler))).Methods("POST")
router.Handle("/user/upload-avatar", Adapt(handler, UploadAvatar(handler, n.conf), ValidateTokenMiddleware(handler, n.conf), Logging(handler))).Methods("POST")
router.Handle("/user/get-avatar", Adapt(handler, DownloadAvatar(handler), ValidateTokenMiddleware(handler, n.conf), Logging(handler))).
Queries("u", "{u}").Methods("GET")
router.Handle("/user/search", Adapt(handler, SearchUsers(handler), ValidateTokenMiddleware(handler, n.conf), Logging(handler))).
Queries("q", "{q}").Methods("GET")
router.Handle("/user/get/{user}", Adapt(handler, GetUser(handler), ValidateTokenMiddleware(handler, n.conf), Logging(handler))).Methods("GET")
router.Handle("/user/balance", Adapt(handler, GetUserBalance(handler), ValidateTokenMiddleware(handler, n.conf), Logging(handler))).Methods("GET")
router.Handle("/contacts/add", Adapt(handler, AddContact(handler), ValidateTokenMiddleware(handler, n.conf), Logging(handler))).
Queries("u", "{u}").Methods("GET")
router.Handle("/contacts/get", Adapt(handler, GetUserContacts(handler), ValidateTokenMiddleware(handler, n.conf), Logging(handler))).Methods("GET")
router.Handle("/contracts/submit/{cid}", Adapt(handler, SubmitCarContract(handler), ValidateTokenMiddleware(handler, n.conf), Logging(handler))).Methods("GET")
router.Handle("/contracts/get", Adapt(handler, GetUserContracts(handler), ValidateTokenMiddleware(handler, n.conf), Logging(handler))).Methods("GET")
router.Handle("/contracts/fields", Adapt(handler, GetContractFieldsList(handler), ValidateTokenMiddleware(handler, n.conf), Logging(handler))).Methods("GET")
router.Handle("/contracts/add", Adapt(handler, CreateCarContract(handler, n.contracts), ValidateTokenMiddleware(handler, n.conf), Logging(handler))).Methods("POST")
router.Handle("/contracts/update", Adapt(handler, UpdateCarContract(handler), ValidateTokenMiddleware(handler, n.conf), Logging(handler))).Methods("POST")
router.Handle("/contracts/get/{cid}", Adapt(handler, GetContract(handler), ValidateTokenMiddleware(handler, n.conf), Logging(handler))).Methods("GET")
router.HandleFunc("/subscribe/register/{uid}", ws.ServeRegWs).Methods("GET")
router.HandleFunc("/subscribe/contract/{uid}", ws.ServeContractWs).Methods("GET")
return router
}