Function leptos_spin::redirect

source ·
pub fn redirect(path: &str)
Expand description

Provides an easy way to redirect the user from within a server function.

This sets the Location header to the URL given.

If the route or server function in which this is called is being accessed by an ordinary GET request or an HTML <form> without any enhancement, it also sets a status code of 302 for a temporary redirect. (This is determined by whether the Accept header contains text/html as it does for an ordinary navigation.)

Otherwise, it sets a custom header that indicates to the client that it should redirect, without actually setting the status code. This means that the client will not follow the redirect, and can therefore return the value of the server function and then handle the redirect with client-side routing.