-
Notifications
You must be signed in to change notification settings - Fork 164
Add support for Ntex #482
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
base: main
Are you sure you want to change the base?
Add support for Ntex #482
Conversation
* feat: add ntex support
maud/src/lib.rs
Outdated
if self.0.is_empty() { | ||
Poll::Ready(None) | ||
} else { | ||
Poll::Ready(Some(Ok(Bytes::from(mem::take(&mut self.0).into_bytes())))) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we forward to the implementation for String
?
if self.0.is_empty() { | |
Poll::Ready(None) | |
} else { | |
Poll::Ready(Some(Ok(Bytes::from(mem::take(&mut self.0).into_bytes())))) | |
} | |
self.0.poll_next_chunk(context) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The implementation follows ntex impl MessageBody for String
, avoiding unnecessary allocations and one-shot consumption of the body, performance wise it's the best.
use crate::PreEscaped; | ||
use alloc::{rc::Rc, string::String}; | ||
|
||
impl MessageBody for PreEscaped<String> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is implementing MessageBody
necessary here, given that we implement Responder
directly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The MessageBody
adds flexibility, allowing maud to be used anywhere the body it's accepted, not only in the Responder.
Co-authored-by: Chris Wong <[email protected]>
I'm suggesting to call the String implementation, instead of duplicating it.
…On Mon, Sep 29, 2025, 01:52 David Miguel ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In maud/src/lib.rs
<#482 (comment)>:
> + if self.0.is_empty() {
+ Poll::Ready(None)
+ } else {
+ Poll::Ready(Some(Ok(Bytes::from(mem::take(&mut self.0).into_bytes()))))
+ }
The implementation follows ntex impl MessageBody for String
<https://github.com/ntex-rs/ntex/blob/6d1aa23d929c485710643ae78abbf3f03d4b7514/ntex-http/src/body.rs#L383>,
avoiding unnecessary allocations and one-shot consumption of the body,
performance wise it's the best.
—
Reply to this email directly, view it on GitHub
<#482 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAL73Y3NVJQAAVKWA6NVS2L3U773XAVCNFSM6AAAAACG2FFTS6VHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZTENZXGEYTSMBUGI>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm more in favor to keep PR as-is, it's copy&paste of actix-web
implementation to ntex
's, making the transition between frameworks actix-web
and ntex
easier.
This PR adds support for the Ntex framework.