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

Move Html from axum-extra to axum #2633

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions axum-extra/src/response/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,6 @@ macro_rules! mime_response {
};
}

mime_response! {
/// A HTML response.
///
/// Will automatically get `Content-Type: text/html; charset=utf-8`.
Html,
TEXT_HTML_UTF_8,
}

mime_response! {
/// A JavaScript response.
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ error[E0277]: the trait bound `bool: FromRequestParts<()>` is not satisfied
<Version as FromRequestParts<S>>
<Extensions as FromRequestParts<S>>
<ConnectInfo<T> as FromRequestParts<S>>
<Extensions as FromRequestParts<S>>
and $N others
= note: required for `bool` to implement `FromRequest<(), axum_core::extract::private::ViaParts>`
note: required by a bound in `__axum_macros_check_handler_0_from_request_check`
Expand Down
11 changes: 4 additions & 7 deletions axum/src/response/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#![doc = include_str!("../docs/response.md")]

use axum_core::body::Body;
use http::{header, HeaderValue};

mod redirect;

#[cfg(feature = "tokio")]
Expand Down Expand Up @@ -40,15 +37,15 @@ pub struct Html<T>(pub T);

impl<T> IntoResponse for Html<T>
where
T: Into<Body>,
T: IntoResponse,
{
fn into_response(self) -> Response {
(
[(
header::CONTENT_TYPE,
HeaderValue::from_static(mime::TEXT_HTML_UTF_8.as_ref()),
http::header::CONTENT_TYPE,
http::HeaderValue::from_static(mime::TEXT_HTML_UTF_8.as_ref()),
Comment on lines +45 to +46
Copy link
Member

Choose a reason for hiding this comment

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

Why add http:: when those symbols are already imported?

)],
self.0.into(),
self.0,
)
.into_response()
}
Expand Down
Loading