mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-07 04:40:05 -06:00
enhancement(graph): refrain from registering routes via the Router interface
After some back an forth we agreed on keeping the routes defined in a central place for now. (cherry picked from commit e7985f42b6edf92f0a4344d4f3f8c5e28c23e276)
This commit is contained in:
@@ -182,14 +182,6 @@ func NewDrivesDriveItemApi(drivesDriveItemService DrivesDriveItemProvider, logge
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Routes returns the routes that should be registered for this api
|
||||
func (api DrivesDriveItemApi) Routes() []Route {
|
||||
return []Route{
|
||||
{http.MethodPost, "/v1beta1/drives/{driveID}/items/{itemID}/children", api.CreateDriveItem},
|
||||
{http.MethodDelete, "/v1beta1/drives/{driveID}/items/{itemID}", api.DeleteDriveItem},
|
||||
}
|
||||
}
|
||||
|
||||
func (api DrivesDriveItemApi) DeleteDriveItem(w http.ResponseWriter, r *http.Request) {
|
||||
ctx := r.Context()
|
||||
_, itemID, err := GetDriveAndItemIDParam(r, &api.logger)
|
||||
|
||||
@@ -59,18 +59,6 @@ type RoleService interface {
|
||||
RemoveRoleFromUser(ctx context.Context, in *settingssvc.RemoveRoleFromUserRequest, opts ...client.CallOption) (*emptypb.Empty, error)
|
||||
}
|
||||
|
||||
// A Route defines the parameters for an api endpoint
|
||||
type Route struct {
|
||||
Method string
|
||||
Pattern string
|
||||
HandlerFunc http.HandlerFunc
|
||||
}
|
||||
|
||||
// Router defines the required methods for retrieving api routes
|
||||
type Router interface {
|
||||
Routes() []Route
|
||||
}
|
||||
|
||||
// Graph defines implements the business logic for Service.
|
||||
type Graph struct {
|
||||
config *config.Config
|
||||
|
||||
@@ -217,14 +217,6 @@ func NewService(opts ...Option) (Graph, error) {
|
||||
m.Route(options.Config.HTTP.Root, func(r chi.Router) {
|
||||
r.Use(middleware.StripSlashes)
|
||||
|
||||
for _, router := range []Router{
|
||||
drivesDriveItemApi,
|
||||
} {
|
||||
for _, route := range router.Routes() {
|
||||
r.Method(route.Method, route.Pattern, route.HandlerFunc)
|
||||
}
|
||||
}
|
||||
|
||||
r.Route("/v1beta1", func(r chi.Router) {
|
||||
r.Route("/me", func(r chi.Router) {
|
||||
r.Get("/drives", svc.GetDrives(APIVersion_1_Beta_1))
|
||||
@@ -236,6 +228,8 @@ func NewService(opts ...Option) (Graph, error) {
|
||||
r.Route("/drives", func(r chi.Router) {
|
||||
r.Get("/", svc.GetAllDrives(APIVersion_1_Beta_1))
|
||||
r.Route("/{driveID}/items/{itemID}", func(r chi.Router) {
|
||||
r.Delete("/", drivesDriveItemApi.DeleteDriveItem)
|
||||
r.Post("/children", drivesDriveItemApi.CreateDriveItem)
|
||||
r.Post("/invite", svc.Invite)
|
||||
r.Route("/permissions", func(r chi.Router) {
|
||||
r.Get("/", svc.ListPermissions)
|
||||
|
||||
Reference in New Issue
Block a user