Navigation Menu

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

Add ServiceConfig::default_service #2338

Closed

Conversation

lily-mara
Copy link

@lily-mara lily-mara commented Jul 20, 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

The App struct supports a "default" service which will be called when there
are no other matching services available. I propose that we support adding this
default service from the ServiceConfig struct, which will enable it to be used
from App::configure. Currently if you want to test a default service (if
you're creating a proxy for example) you must re-specify this default service
each time you construct your app. This change will allow users to put their
default services into the shared App::configure helper.

The `App` struct supports a "default" service which will be called when there
are no other matching services available. I propose that we support adding this
default service from the `ServiceConfig` struct, which will enable it to be used
from `App::configure`. Currently if you want to test a default service (if
you're creating a proxy for example) you must re-specify this default service
each time you construct your app. This change will allow users to put their
default services into the shared `App::configure` helper.
Comment on lines +208 to +211
if let Some(default) = cfg.default {
self.default = Some(default);
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should have this for Scope::configure as well.

@robjtede robjtede added C-improvement Category: an improvement to existing functionality A-web project: actix-web B-semver-minor and removed C-improvement Category: an improvement to existing functionality labels Oct 11, 2021
@robjtede robjtede added this to the actix-web post-v4 milestone Nov 24, 2021
@robjtede robjtede modified the milestones: actix-web post-v4, actix-web v4.1 Mar 1, 2022
robjtede added a commit that referenced this pull request Apr 23, 2022
@robjtede robjtede mentioned this pull request Apr 23, 2022
5 tasks
@robjtede
Copy link
Member

robjtede commented Apr 23, 2022

The source branch does not allow maintainer edits so i've carried on the work in #2743 with attribution back here.

Thanks for the contribution.

@robjtede robjtede closed this Apr 23, 2022
robjtede added a commit that referenced this pull request Apr 23, 2022
* Add `ServiceConfig::default_service`

based on #2338

* update changelog
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
Development

Successfully merging this pull request may close these issues.

None yet

3 participants