forked from refiito/pipes-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
routes.go
37 lines (28 loc) · 1.84 KB
/
routes.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
package main
import (
"github.com/gorilla/mux"
"net/http"
)
type Router struct {
Routes *mux.Router
}
var routes *Router
func init() {
routes = &Router{Routes: mux.NewRouter()}
v1 := routes.Routes.PathPrefix("/api/v1").Subrouter()
v1.HandleFunc("/status", handleRequest(getStatus)).Methods("GET")
v1.HandleFunc("/integrations", withAuth(handleRequest(getIntegrations))).Methods("GET")
v1.HandleFunc("/integrations/{service}/pipes/{pipe}", withAuth(handleRequest(getIntegrationPipe))).Methods("GET")
v1.HandleFunc("/integrations/{service}/pipes/{pipe}/setup", withAuth(handleRequest(putPipeSetup))).Methods("PUT")
v1.HandleFunc("/integrations/{service}/pipes/{pipe}/setup", withAuth(handleRequest(postPipeSetup))).Methods("POST")
v1.HandleFunc("/integrations/{service}/pipes/{pipe}/setup", withAuth(handleRequest(deletePipeSetup))).Methods("DELETE")
v1.HandleFunc("/integrations/{service}/pipes/{pipe}/log", withService(withAuth(handleRequest(getServicePipeLog)))).Methods("GET")
v1.HandleFunc("/integrations/{service}/pipes/{pipe}/clear_connections", withService(withAuth(handleRequest(postServicePipeClearConnections)))).Methods("POST")
v1.HandleFunc("/integrations/{service}/accounts", withAuth(handleRequest(getServiceAccounts))).Methods("GET")
v1.HandleFunc("/integrations/{service}/auth_url", withAuth(handleRequest(getAuthURL))).Methods("GET")
v1.HandleFunc("/integrations/{service}/authorizations", withAuth(handleRequest(postAuthorization))).Methods("POST")
v1.HandleFunc("/integrations/{service}/authorizations", withAuth(handleRequest(deleteAuthorization))).Methods("DELETE")
v1.HandleFunc("/integrations/{service}/pipes/{pipe}/users", withAuth(handleRequest(getServiceUsers))).Methods("GET")
v1.HandleFunc("/integrations/{service}/pipes/{pipe}/run", withService(withAuth(handleRequest(postPipeRun)))).Methods("POST")
http.Handle("/", routes)
}