Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: multiple routers #1

Merged
merged 2 commits into from
Aug 31, 2024
Merged

feat: multiple routers #1

merged 2 commits into from
Aug 31, 2024

Conversation

iyifr
Copy link
Owner

@iyifr iyifr commented Aug 31, 2024

You can now use multiple routers in H4

void main() async {
  var app = createApp(
    port: 5173,
    onRequest: (event) {},
    afterResponse: (event) => {},
  );

  var router = createRouter();
  var apiRouter = createRouter();

  app.use(router, basePath: '/');
  app.use(apiRouter, basePath: '/api');

  router.get("/", (event) {
    return 'Hello from /';
  });

  apiRouter.get("/", (event) {
    return 'Hi from /api';
  });
}

Non breaking change to app.use(H4Router) which can now be extended to be

app.use(H4Router, basePath: String)

@iyifr iyifr merged commit baad725 into main Aug 31, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant