@@ -50,42 +50,48 @@ var (
50
50
// PUBLIC METHODS - ENDPOINTS
51
51
52
52
// Add endpoints to the router
53
- func (service * nginx ) AddEndpoints (ctx context.Context , router server.Router ) {
53
+ func (service * nginx ) AddEndpoints (ctx context.Context , r server.Router ) {
54
54
// Path: /
55
55
// Methods: GET
56
- // Scopes: read // TODO: Add scopes
56
+ // Scopes: read
57
57
// Description: Get nginx status (version, uptime, available and enabled configurations)
58
- router .AddHandlerFuncRe (ctx , reRoot , service .GetHealth , http .MethodGet )
58
+ r .AddHandlerFuncRe (ctx , reRoot , service .GetHealth , http .MethodGet ).(router.Route ).
59
+ SetScope (service .ScopeRead ()... )
59
60
60
61
// Path: /(test|reload|reopen)
61
62
// Methods: PUT
62
- // Scopes: write // TODO: Add scopes
63
+ // Scopes: write
63
64
// Description: Test, reload and reopen nginx configuration
64
- router .AddHandlerFuncRe (ctx , reAction , service .PutAction , http .MethodPut )
65
+ r .AddHandlerFuncRe (ctx , reAction , service .PutAction , http .MethodPut ).(router.Route ).
66
+ SetScope (service .ScopeWrite ()... )
65
67
66
68
// Path: /config
67
69
// Methods: GET
68
- // Scopes: read // TODO: Add scopes
70
+ // Scopes: read
69
71
// Description: Read the current set of configurations
70
- router .AddHandlerFuncRe (ctx , reListConfig , service .ListConfig , http .MethodGet )
72
+ r .AddHandlerFuncRe (ctx , reListConfig , service .ListConfig , http .MethodGet ).(router.Route ).
73
+ SetScope (service .ScopeRead ()... )
71
74
72
75
// Path: /config
73
76
// Methods: POST
74
- // Scopes: read // TODO: Add scopes
77
+ // Scopes: write
75
78
// Description: Create a new configuration
76
- router .AddHandlerFuncRe (ctx , reListConfig , service .CreateConfig , http .MethodPost )
79
+ r .AddHandlerFuncRe (ctx , reListConfig , service .CreateConfig , http .MethodPost ).(router.Route ).
80
+ SetScope (service .ScopeWrite ()... )
77
81
78
82
// Path: /config/{id}
79
83
// Methods: GET
80
- // Scopes: read // TODO: Add scopes
84
+ // Scopes: read
81
85
// Description: Read a configuration
82
- router .AddHandlerFuncRe (ctx , reConfig , service .ReadConfig , http .MethodGet )
86
+ r .AddHandlerFuncRe (ctx , reConfig , service .ReadConfig , http .MethodGet ).(router.Route ).
87
+ SetScope (service .ScopeRead ()... )
83
88
84
89
// Path: /config/{id}
85
90
// Methods: DELETE, POST, PATCH
86
- // Scopes: write // TODO: Add scopes
91
+ // Scopes: write
87
92
// Description: Modify a configuration
88
- router .AddHandlerFuncRe (ctx , reConfig , service .WriteConfig , http .MethodDelete , http .MethodPatch )
93
+ r .AddHandlerFuncRe (ctx , reConfig , service .WriteConfig , http .MethodDelete , http .MethodPatch ).(router.Route ).
94
+ SetScope (service .ScopeWrite ()... )
89
95
}
90
96
91
97
///////////////////////////////////////////////////////////////////////////////
0 commit comments