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

Introduce Group #2264

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

Introduce Group #2264

wants to merge 1 commit into from

Conversation

aliemjay
Copy link
Member

@aliemjay aliemjay commented Jun 16, 2021

PR Type

Feature

PR Checklist

  • Tests for the changes have been added / updated.
  • Documentation comments have been added / updated.
  • A changelog entry has been made for the appropriate packages.
  • Format code with the latest stable rustfmt.
  • (Team) Label with affected crates and semver status.

Overview

This tries to implement #414 . I implemented these changes on Scope temporarily to use existing tests and for smaller diff.

The new behavior for scope is equivalent to registering component services individually. This allows the scope to fallthrough when no matching route is found (instead of calling default service). A typical use case would be:

app
.service(
    web::scope("/users")
        .wrap(no_auth_needed)
        .route("u1", web::get().to(handle_u1))
        .route("u2", web::get().to(handle_u2)),
)
.service(
    web::scope("/users")
        .wrap(need_auth)
        .route("{user}", handle_other_users),
)

Setting Scope::default_service(), would make it mimic the original behavior.

As a side-effect, this will also make #2096 possible.

Open questions

This introduces new API. So I'm looking for input before finishing it. Specifically, I'm looking for the naming (eg. EndpointConstructor trait) and what mehods to have for it.

Closes #414
Closes #2096

@aliemjay aliemjay requested a review from a team June 16, 2021 05:21
@robjtede robjtede changed the title [RFC] Introducing Group #414 ?? Introduce Group Jun 16, 2021
@robjtede robjtede added A-web project: actix-web B-semver-minor labels Jun 16, 2021
@aliemjay aliemjay marked this pull request as draft June 19, 2021 16:14
@aliemjay aliemjay added this to the actix-web post-v4 milestone Jul 2, 2021
@robjtede robjtede removed this from the actix-web post-v4 milestone Mar 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-web project: actix-web B-semver-minor
Projects
None yet
2 participants