Skip to content

Commit

Permalink
chore: refactor shared http routes/paths implementation
Browse files Browse the repository at this point in the history
Add away to add new service specific route/path

Signed-off-by: Otieno Calvine <nyarangaotieno@gmail.com>
  • Loading branch information
NYARAS committed Sep 16, 2021
1 parent 2c9ce38 commit 029968a
Show file tree
Hide file tree
Showing 2 changed files with 1,944 additions and 1,933 deletions.
12 changes: 9 additions & 3 deletions pkg/onboarding/presentation/routes.go
Expand Up @@ -18,7 +18,7 @@ func SharedRoutes(handlers rest.HandlersInterfaces, r *mux.Router) {
}

// SharedUnauthenticatedRoutes return REST routes shared by open/closed onboarding services
func SharedUnauthenticatedRoutes(handlers rest.HandlersInterfaces, r *mux.Router) {
func SharedUnauthenticatedRoutes(handlers rest.HandlersInterfaces, r *mux.Router) *mux.Router {
// Unauthenticated routes
r.Path("/switch_flagged_features").Methods(
http.MethodPost,
Expand Down Expand Up @@ -102,10 +102,12 @@ func SharedUnauthenticatedRoutes(handlers rest.HandlersInterfaces, r *mux.Router
http.MethodPost,
http.MethodOptions).
HandlerFunc(handlers.RemoveAdminPermsToUser())

return r
}

// SharedAuthenticatedRoutes return REST routes shared by open/closed onboarding services
func SharedAuthenticatedRoutes(handlers rest.HandlersInterfaces, r *mux.Router) {
func SharedAuthenticatedRoutes(handlers rest.HandlersInterfaces, r *mux.Router) *mux.Router {
fc := &firebasetools.FirebaseClient{}
firebaseApp, _ := fc.InitFirebase()

Expand Down Expand Up @@ -135,10 +137,12 @@ func SharedAuthenticatedRoutes(handlers rest.HandlersInterfaces, r *mux.Router)
http.MethodOptions).
HandlerFunc(handlers.RemoveRoleToUser())

return r

}

// SharedAuthenticatedISCRoutes return ISC REST routes shared by open/closed onboarding services
func SharedAuthenticatedISCRoutes(handlers rest.HandlersInterfaces, r *mux.Router) {
func SharedAuthenticatedISCRoutes(handlers rest.HandlersInterfaces, r *mux.Router) *mux.Router {
// Interservice Authenticated routes
isc := r.PathPrefix("/internal").Subrouter()
isc.Use(interserviceclient.InterServiceAuthenticationMiddleware())
Expand Down Expand Up @@ -218,4 +222,6 @@ func SharedAuthenticatedISCRoutes(handlers rest.HandlersInterfaces, r *mux.Route
http.MethodPost,
http.MethodOptions).
HandlerFunc(handlers.RemoveRoleByName())

return r
}

0 comments on commit 029968a

Please sign in to comment.