pub struct Outcome { /* private fields */ }Expand description
What an Action or a HeaderAction asks of the
response once its write commits: which notification it flashes and where it lands.
Outcome::done keeps the defaults: the action’s success
notification, landing back where the action ran from. A run builds on it:
// Report what happened, and open the copy the action made.
let outcome = Outcome::done()
.notify(
Notification::warning(format!("{sent} sent")).description(format!("{bounced} bounced")),
)
.redirect(format!("/admin/invoices/{id}"));A file to download is a redirect to an app route that serves it.
Implementations§
Source§impl Outcome
impl Outcome
Sourcepub fn done() -> Self
pub fn done() -> Self
The defaults: the action’s success notification, landing where it ran from.
Sourcepub fn notify(self, notification: Notification) -> Self
pub fn notify(self, notification: Notification) -> Self
Flashes notification instead of the action’s success notification. A bulk run that
skipped records appends their count to its title.
Sourcepub fn redirect(self, path: impl Into<String>) -> Self
pub fn redirect(self, path: impl Into<String>) -> Self
Lands on path instead of where the action ran from. path is a same-origin path such
as /admin/invoices/42; anything else, such as https://… or //host, lands where the
action ran from and logs an error, since the write has already committed.
Sourcepub fn redirect_off_site(self, url: impl Into<String>) -> Self
pub fn redirect_off_site(self, url: impl Into<String>) -> Self
Lands on url on another site, such as a payment provider’s checkout page the action
just opened a session for. url is an http or https URL the app builds, never one a
request carries: anything else lands where the action ran from and logs an error, since
the write has already committed.
The browser follows the redirect of a form it posted only to an origin the panel’s
form-action allows, so add the site’s origin with
Panel::content_security_policy_source.