diff --git a/examples/auth/main.go b/examples/auth/main.go index 373e41c..4d6d36d 100644 --- a/examples/auth/main.go +++ b/examples/auth/main.go @@ -65,9 +65,20 @@ func main() { handleOAuthCallback() return } + router := navigation.NewRouter(getRoutes()) + router.SetNotFoundHandler(notFoundView) + navigation.SetGlobalRouter(router) - // Set up routes - routes := []navigation.Route{ + // Create the main app with router + ui.NewAppWithRouter(router) + + // Keep the application running + select {} +} + +// getRoutes returns the route configuration for the application +func getRoutes() []navigation.Route { + return []navigation.Route{ { Path: "/", Handler: homeView, @@ -87,16 +98,6 @@ func main() { Guards: []navigation.RouteGuard{authGuard()}, }, } - - router := navigation.NewRouter(routes) - router.SetNotFoundHandler(notFoundView) - navigation.SetGlobalRouter(router) - - // Create the main app with router - ui.NewAppWithRouter(router) - - // Keep the application running - select {} } // checkExistingSession checks for existing valid tokens @@ -150,28 +151,7 @@ func handleOAuthCallback() { // renderApp initializes and renders the app after callback processing func renderApp() { - routes := []navigation.Route{ - { - Path: "/", - Handler: homeView, - }, - { - Path: "/callback", - Handler: callbackView, - }, - { - Path: "/profile", - Handler: profileView, - Guards: []navigation.RouteGuard{authGuard()}, - }, - { - Path: "/protected", - Handler: protectedView, - Guards: []navigation.RouteGuard{authGuard()}, - }, - } - - router := navigation.NewRouter(routes) + router := navigation.NewRouter(getRoutes()) router.SetNotFoundHandler(notFoundView) navigation.SetGlobalRouter(router)