[][src]Struct rocket::response::Redirect

pub struct Redirect(_, _);

An empty redirect response to a given URL.

This type simplifies returning a redirect response to the client.

Methods

impl Redirect
[src]

Construct a temporary "see other" (303) redirect response. This is the typical response when redirecting a user to another page. This type of redirect indicates that the client should look elsewhere, but always via a GET request, for a given resource.

Examples

use rocket::response::Redirect;

let redirect = Redirect::to("/other_url");

Construct a "temporary" (307) redirect response. This response instructs the client to reissue the current request to a different URL, maintaining the contents of the request identically. This means that, for example, a POST request will be resent, contents included, to the requested URL.

Examples

use rocket::response::Redirect;

let redirect = Redirect::temporary("/other_url");

Construct a "permanent" (308) redirect response. This redirect must only be used for permanent redirects as it is cached by clients. This response instructs the client to reissue requests for the current URL to a different URL, now and in the future, maintaining the contents of the request identically. This means that, for example, a POST request will be resent, contents included, to the requested URL.

Examples

use rocket::response::Redirect;

let redirect = Redirect::permanent("/other_url");

Construct a temporary "found" (302) redirect response. This response instructs the client to reissue the current request to a different URL, ideally maintaining the contents of the request identically. Unfortunately, different clients may respond differently to this type of redirect, so 303 or 307 redirects, which disambiguate, are preferred.

Examples

use rocket::response::Redirect;

let redirect = Redirect::found("/other_url");

Construct a permanent "moved" (301) redirect response. This response should only be used for permanent redirects as it can be cached by browsers. Because different clients may respond differently to this type of redirect, a 308 redirect, which disambiguates, is preferred.

Examples

use rocket::response::Redirect;

let redirect = Redirect::moved("/other_url");

Trait Implementations

impl Responder<'static> for Redirect
[src]

Constructs a response with the appropriate status code and the given URL in the Location header field. The body of the response is empty. This responder does not fail.

Returns Ok if a Response could be generated successfully. Otherwise, returns an Err with a failing Status. Read more

impl Debug for Redirect
[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl Send for Redirect

impl Sync for Redirect

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

Performs the conversion.

impl<T> From for T
[src]

Performs the conversion.

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

🔬 This is a nightly-only experimental API. (try_from)

Performs the conversion.

impl<T> Borrow for T where
    T: ?Sized
[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut for T where
    T: ?Sized
[src]

Mutably borrows from an owned value. Read more

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

🔬 This is a nightly-only experimental API. (try_from)

Performs the conversion.

impl<T> Any for T where
    T: 'static + ?Sized
[src]

🔬 This is a nightly-only experimental API. (get_type_id)

this method will likely be replaced by an associated static

Gets the TypeId of self. Read more

impl<T> Typeable for T where
    T: Any

Get the TypeId of this object.