Skip to main content
The 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 implements IntoResponse:

How it works

IntoResponse implementation

The Html type is a simple wrapper that sets the content-type header:
See implementation in axum/src/response/mod.rs:32-53.

Type definition

The inner value is public, allowing direct access and construction.

Response fields

header
Automatically set to text/html; charset=utf-8
T
The inner response body (must implement IntoResponse)

Common patterns

Serving static HTML

With template rendering

Serving multipart forms

Example from examples/stream-to-file/src/main.rs:60-85.

With custom status codes

Using From trait

See also