forked from cloudfoundry/rep
-
Notifications
You must be signed in to change notification settings - Fork 0
/
routes.go
47 lines (36 loc) · 1.45 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
46
47
package rep
import "github.com/tedsuo/rata"
const (
StateRoute = "STATE"
ContainerMetricsRoute = "ContainerMetrics"
PerformRoute = "PERFORM"
UpdateLRPInstanceRoute = "UpdateLRPInstance"
StopLRPInstanceRoute = "StopLRPInstance"
CancelTaskRoute = "CancelTask"
SimResetRoute = "RESET"
PingRoute = "Ping"
EvacuateRoute = "Evacuate"
)
func NewRoutes(networkAccessible bool) rata.Routes {
var routes rata.Routes
if networkAccessible {
routes = append(routes,
rata.Route{Path: "/state", Method: "GET", Name: StateRoute},
rata.Route{Path: "/container_metrics", Method: "GET", Name: ContainerMetricsRoute},
rata.Route{Path: "/work", Method: "POST", Name: PerformRoute},
rata.Route{Path: "/v1/lrps/:process_guid/instances/:instance_guid", Method: "PUT", Name: UpdateLRPInstanceRoute},
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: SimResetRoute},
)
} else {
routes = append(routes,
rata.Route{Path: "/ping", Method: "GET", Name: PingRoute},
rata.Route{Path: "/evacuate", Method: "POST", Name: EvacuateRoute},
)
}
return routes
}
var RoutesLocalhostOnly = NewRoutes(false)
var RoutesNetworkAccessible = NewRoutes(true)
var Routes = append(RoutesLocalhostOnly, RoutesNetworkAccessible...)