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

Make it possible to merge routes #101

Closed
davidpdrsn opened this issue Aug 3, 2021 · 0 comments · Fixed by #108
Closed

Make it possible to merge routes #101

davidpdrsn opened this issue Aug 3, 2021 · 0 comments · Fixed by #108
Labels
C-feature-request Category: A feature request, i.e: not implemented / a PR.
Milestone

Comments

@davidpdrsn
Copy link
Member

Being able to merge routes/apps like this would be really cool

let app = route("/foo", get(|| async {}));
let other_route = route("/bar", get(|| async {}));

// this accepts `GET /foo` and `GET /bar`
let merged = app.or(other_route);

Things to consider:

  • It should work with other things than Route like BoxRoute, Nested, basically anything that implements RouteDsl.
@davidpdrsn davidpdrsn added the C-feature-request Category: A feature request, i.e: not implemented / a PR. label Aug 3, 2021
davidpdrsn added a commit that referenced this issue Aug 3, 2021
With this you'll be able to do:

```rust
let one = route("/foo", get(|| async { "foo" }))
    .route("/bar", get(|| async { "bar" }));

let two = route("/baz", get(|| async { "baz" }));

let app = one.or(two);
```

Fixes #101
@davidpdrsn davidpdrsn added this to the 0.2 milestone Aug 4, 2021
davidpdrsn added a commit that referenced this issue Aug 7, 2021
With this you'll be able to do:

```rust
let one = route("/foo", get(|| async { "foo" }))
    .route("/bar", get(|| async { "bar" }));

let two = route("/baz", get(|| async { "baz" }));

let app = one.or(two);
```

Fixes #101
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: A feature request, i.e: not implemented / a PR.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant