forked from cloudfoundry/rep
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroutes.go
45 lines (33 loc) · 1.1 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
38
39
40
41
42
43
44
45
package rep
import "github.com/tedsuo/rata"
const (
StateRoute = "STATE"
PerformRoute = "PERFORM"
StopLRPInstanceRoute = "StopLRPInstance"
CancelTaskRoute = "CancelTask"
Sim_ResetRoute = "RESET"
PingRoute = "Ping"
EvacuateRoute = "Evacuate"
)
func NewRoutes(secure bool) rata.Routes {
var routes rata.Routes
if secure {
routes = append(routes,
rata.Route{Path: "/state", Method: "GET", Name: StateRoute},
rata.Route{Path: "/work", Method: "POST", Name: PerformRoute},
rata.Route{Path: "/v1/lrps/:process_guid/instances/:instance_guid/stop", Method: "POST", Name: StopLRPInstanceRoute},
rata.Route{Path: "/v1/tasks/:task_guid/cancel", Method: "POST", Name: CancelTaskRoute},
rata.Route{Path: "/sim/reset", Method: "POST", Name: Sim_ResetRoute},
)
}
if !secure {
routes = append(routes,
rata.Route{Path: "/ping", Method: "GET", Name: PingRoute},
rata.Route{Path: "/evacuate", Method: "POST", Name: EvacuateRoute},
)
}
return routes
}
var RoutesInsecure = NewRoutes(false)
var RoutesSecure = NewRoutes(true)
var Routes = append(RoutesInsecure, RoutesSecure...)