Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upFix nested cookies #400
Open
Fix nested cookies #400
+58
−8
Conversation
This comment has been minimized.
This comment has been minimized.
|
Just throwing it out there. Should you provide a function to listen without any default middleware? |
| /// # Middleware | ||
| /// | ||
| /// This method does not enable default middleware. See `into_mock` for | ||
| /// converting Tide into a server that can be used for testing purposes. | ||
| pub fn into_http_service(self) -> Service<State> { |
This comment has been minimized.
This comment has been minimized.
tirr-c
Feb 2, 2020
Collaborator
How about leaving this as is, and provide a new method that doesn't apply any default middleware? One rarely calls .into_http_service() directly for nesting since Route::nest handles it instead, so I think it should be okay?
| /// Convert the server into a mock server. | ||
| /// | ||
| /// Unlike `into_http_service` this method enables default middleware. | ||
| /// | ||
| /// # Stability | ||
| /// | ||
| /// This method will be expanded in the future to allow mocking requests | ||
| /// in a more direct manner. | ||
| pub fn into_mock(mut self) -> io::Result<http_service_mock::TestBackend<Service<State>>> { | ||
| self.enable_default_middleware(); | ||
| let server = http_service_mock::make_server(self.into_http_service())?; | ||
| Ok(server) | ||
| } |
Comment on lines
+333
to
+345
This comment has been minimized.
This comment has been minimized.
tirr-c
Feb 2, 2020
Collaborator
By providing separate method for nesting, we don't need to provide a "special" wrapper method like this.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
yoshuawuyts commentedFeb 1, 2020
•
edited
Fixes #396 by ensuring the cookies middleware is only created when we actually call
.listenand not when nested.This also adds a
into_mockmethod so that the cookies middleware can still be constructed when running tests. This seemed like a good setup to start improving our test workflow, by at least starting to remove some of the boilerplate involved now.Thanks!