pub struct Template<'a> { /* private fields */ }Expand description
Modifiable reason for creating a response to the client.
Not all responses indicate failure. A redirect will also occur in the a regular of providing an access token to the third party client. When an error is present (see several methods) it is mostly possible to customize it. This hook provides advanced endpoints with the opportunity to set additional parameters and informational messages before they are encoded.
See the provided methods for more information and examples.
Implementations§
Source§impl<'a> Template<'a>
impl<'a> Template<'a>
Sourcepub fn new_bad(access_token_error: Option<&'a mut AccessTokenError>) -> Self
pub fn new_bad(access_token_error: Option<&'a mut AccessTokenError>) -> Self
Create a bad request template
Create an unauthorized template
Sourcepub fn new_redirect(
authorization_error: Option<&'a mut AuthorizationError>,
) -> Self
pub fn new_redirect( authorization_error: Option<&'a mut AuthorizationError>, ) -> Self
Create a redirect template
Sourcepub fn status(&self) -> ResponseStatus
pub fn status(&self) -> ResponseStatus
The corresponding status code.
Supplementary information about an error in the authorization code flow.
The referenced object can be inspected and manipulated to provided additional information that is specific to this server or endpoint. Such information could be an error page with explanatory information or a customized message.
fn explain(mut template: Template) {
if let Some(error) = template.authorization_error() {
eprintln!("[authorization] An error occurred: {:?}", error.kind());
error.explain("This server is still in its infancy. Sorry.");
error.explain_uri("/authorization_error.html".parse().unwrap());
}
}Sourcepub fn access_token_error(&mut self) -> Option<&mut AccessTokenError>
pub fn access_token_error(&mut self) -> Option<&mut AccessTokenError>
Supplementary information about an error in the access token flow.
The referenced object can be inspected and manipulated to provided additional information that is specific to this server or endpoint. Such information could be an error page with explanatory information or a customized message.
fn explain(mut template: Template) {
if let Some(error) = template.access_token_error() {
eprintln!("[access_code] An error occurred: {:?}", error.kind());
error.explain("This server is still in its infancy. Sorry.");
error.explain_uri("/access_token_error.html".parse().unwrap());
}
}