forked from rexray/rexray
-
Notifications
You must be signed in to change notification settings - Fork 0
/
service.go
54 lines (43 loc) · 1.16 KB
/
service.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
48
49
50
51
52
53
54
package service
import (
gofig "github.com/akutz/gofig/types"
"github.com/codedellemc/rexray/libstorage/api/registry"
"github.com/codedellemc/rexray/libstorage/api/server/handlers"
"github.com/codedellemc/rexray/libstorage/api/server/httputils"
"github.com/codedellemc/rexray/libstorage/api/types"
"github.com/codedellemc/rexray/libstorage/api/utils/schema"
)
func init() {
registry.RegisterRouter(&router{})
}
type router struct {
routes []types.Route
}
func (r *router) Name() string {
return "service-router"
}
func (r *router) Init(config gofig.Config) {
r.initRoutes()
}
// Routes returns the available routes.
func (r *router) Routes() []types.Route {
return r.routes
}
func (r *router) initRoutes() {
r.routes = []types.Route{
// GET
httputils.NewGetRoute(
"services",
"/services",
r.servicesList,
handlers.NewAuthAllSvcsHandler(),
handlers.NewSchemaValidator(nil, schema.ServiceInfoMapSchema, nil)),
httputils.NewGetRoute(
"serviceInspect",
"/services/{service}",
r.serviceInspect,
handlers.NewServiceValidator(),
handlers.NewAuthSvcHandler(),
handlers.NewSchemaValidator(nil, schema.ServiceInfoSchema, nil)),
}
}