Skip to content

impl IntoResponseParts for Redirect #3637

@teohhanhui

Description

@teohhanhui
  • I have looked for existing issues (including closed) about this

Feature Request

Motivation

RFC 9110 specifies this about 303 See Other:

Except for responses to a HEAD request, the representation of a 303 response ought to contain a short hypertext note with a hyperlink to the same URI reference provided in the Location header field.

Proposal

impl IntoResponseParts for Redirect

This would allow doing:

(
    Redirect::to(url),
    Html(format!(
        r#"<p>Redirecting to <a href="{url}">{url}</a></p>"#,
    )),
)

Alternatives

Currently, it'd have to be done manually like this:

(
    StatusCode::SEE_OTHER,
    [(header::LOCATION, url)],
    Html(format!(
        r#"<p>Redirecting to <a href="{url}">{url}</a></p>"#,
    )),
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions