Html response type wraps any response body and automatically sets the Content-Type: text/html; charset=utf-8 header.
Basic usage
Wrap a string or any type that implementsIntoResponse:
How it works
IntoResponse implementation
TheHtml type is a simple wrapper that sets the content-type header:
axum/src/response/mod.rs:32-53.
Type definition
Response fields
header
Automatically set to
text/html; charset=utf-8T
The inner response body (must implement
IntoResponse)Common patterns
Serving static HTML
With template rendering
Serving multipart forms
examples/stream-to-file/src/main.rs:60-85.
With custom status codes
Using From trait
See also
- Response tuples for combining status codes and headers
- IntoResponse trait for custom response types