Conversation
Fixes broken code fences and syntax in the illustrative server example.
Reviewer's GuideIntroduce a functional middleware builder ( Class diagram for functional middleware builder (
|
| Change | Details | Files |
|---|---|---|
| Introduce functional middleware builder |
|
src/middleware.rs |
| Document middleware usage |
|
README.md |
| Fix markdown formatting in design documentation |
|
docs/rust-binary-router-library-design.md |
Tips and commands
Interacting with Sourcery
- Trigger a new review: Comment
@sourcery-ai reviewon the pull request. - Continue discussions: Reply directly to Sourcery's review comments.
- Generate a GitHub issue from a review comment: Ask Sourcery to create an
issue from a review comment by replying to it. You can also reply to a
review comment with@sourcery-ai issueto create an issue from it. - Generate a pull request title: Write
@sourcery-aianywhere in the pull
request title to generate a title at any time. You can also comment
@sourcery-ai titleon the pull request to (re-)generate the title at any time. - Generate a pull request summary: Write
@sourcery-ai summaryanywhere in
the pull request body to generate a PR summary at any time exactly where you
want it. You can also comment@sourcery-ai summaryon the pull request to
(re-)generate the summary at any time. - Generate reviewer's guide: Comment
@sourcery-ai guideon the pull
request to (re-)generate the reviewer's guide at any time. - Resolve all Sourcery comments: Comment
@sourcery-ai resolveon the
pull request to resolve all Sourcery comments. Useful if you've already
addressed all the comments and don't want to see them anymore. - Dismiss all Sourcery reviews: Comment
@sourcery-ai dismisson the pull
request to dismiss all existing Sourcery reviews. Especially useful if you
want to start fresh with a new review - don't forget to comment
@sourcery-ai reviewto trigger a new review!
Customizing Your Experience
Access your dashboard to:
- Enable or disable review features such as the Sourcery-generated pull request
summary, the reviewer's guide, and others. - Change the review language.
- Add, remove or edit custom review instructions.
- Adjust other review settings.
Getting Help
- Contact our support team for questions or feedback.
- Visit our documentation for detailed guides and information.
- Keep in touch with the Sourcery team by following us on X/Twitter, LinkedIn or GitHub.
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThe changes introduce a new function-based middleware mechanism to the codebase, allowing middleware to be constructed from asynchronous functions or closures. Documentation is updated to explain this feature, and the middleware module is extended with new public types and helper functions to support this approach. No changes are made to the core API or exported entities outside the middleware module. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Middleware (FromFn)
participant Next
participant Service
Client->>Middleware (FromFn): send ServiceRequest
Middleware (FromFn)->>Next: call with ServiceRequest
Next->>Service: forward ServiceRequest
Service-->>Next: return ServiceResponse
Next-->>Middleware (FromFn): return ServiceResponse
Middleware (FromFn)-->>Client: return ServiceResponse
Possibly related PRs
Poem
✨ Finishing Touches🧪 Generate Unit Tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Hey @leynos - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `src/middleware.rs:96` </location>
<code_context>
+/// The function receives a [`ServiceRequest`] and a [`Next`] reference to invoke
+/// the remaining middleware chain. It must return a [`ServiceResponse`] wrapped
+/// in a [`Result`]. The error type is the same as the wrapped service.
+pub struct FromFn<F> {
+ f: F,
+}
</code_context>
<issue_to_address>
The module is missing a containing item comment (`//!`).
Please add a module-level doc comment at the top of the file using `//!` to describe the purpose of this module.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 3
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (3)
README.md(1 hunks)docs/rust-binary-router-library-design.md(15 hunks)src/middleware.rs(2 hunks)
🧰 Additional context used
🪛 LanguageTool
docs/rust-binary-router-library-design.md
[grammar] ~333-~333: The verb ‘derives’ is singular. Did you mean: “this derives” or “these derive”?
Context: ...rait in the library currently exposes these derives under a convenient Message trait, pro...
(SINGULAR_VERB_AFTER_THESE_OR_THOSE)
[uncategorized] ~769-~769: Loose punctuation mark.
Context: ...r_addr()); } ``` - SharedState<T>: Allows handlers to access shared applic...
(UNLIKELY_OPENING_PUNCTUATION)
[grammar] ~813-~813: Please add a punctuation mark at the end of paragraph.
Context: ...erate on "wireframe's" internal request and response types, which could be raw f...
(PUNCTUATION_PARAGRAPH_END)
🔇 Additional comments (3)
src/middleware.rs (2)
1-6: LGTM! Module documentation addresses previous feedback.The module-level documentation clearly explains the middleware purpose and usage patterns. This resolves the past review comment about missing containing item comments.
92-104: Consider adding documentation for the FromFn struct.The struct is public but lacks documentation comments explaining its purpose and usage.
Add documentation to the struct:
+/// Middleware factory that wraps an asynchronous function. +/// +/// This struct implements [`Transform`] to create middleware from functions that +/// match the signature `Fn(ServiceRequest, Next<'_, S>) -> impl Future<Output = Result<ServiceResponse, S::Error>>`. pub struct FromFn<F> { f: F, }Likely an incorrect or invalid review comment.
docs/rust-binary-router-library-design.md (1)
332-334: Fix grammatical error in serialization engine description.The static analysis tool correctly identified a subject-verb disagreement.
Apply this grammatical fix:
-A minimal wrapper trait in the library currently -exposes these derives under a convenient `Message` trait, providing `to_bytes` -and `from_bytes` helpers. +A minimal wrapper trait in the library currently +exposes this derive functionality under a convenient `Message` trait, providing `to_bytes` +and `from_bytes` helpers.Likely an incorrect or invalid review comment.
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
Summary
middleware::from_fnto build middleware from async closuresTesting
make fmtmake lintmake testhttps://chatgpt.com/codex/tasks/task_e_68544bc89cfc8322b34b196ee3bb3888
Summary by Sourcery
Implement a functional middleware builder and update documentation accordingly
New Features:
Documentation:
Summary by CodeRabbit