Struct aws_sdk_cloudfront::model::CustomErrorResponse
source · #[non_exhaustive]pub struct CustomErrorResponse { /* private fields */ }
Expand description
A complex type that controls:
-
Whether CloudFront replaces HTTP status codes in the 4xx and 5xx range with custom error messages before returning the response to the viewer.
-
How long CloudFront caches HTTP status codes in the 4xx and 5xx range.
For more information about custom error pages, see Customizing Error Responses in the Amazon CloudFront Developer Guide.
Implementations§
source§impl CustomErrorResponse
impl CustomErrorResponse
sourcepub fn error_code(&self) -> Option<i32>
pub fn error_code(&self) -> Option<i32>
The HTTP status code for which you want to specify a custom error page and/or a caching duration.
sourcepub fn response_page_path(&self) -> Option<&str>
pub fn response_page_path(&self) -> Option<&str>
The path to the custom error page that you want CloudFront to return to a viewer when your origin returns the HTTP status code specified by ErrorCode
, for example, /4xx-errors/403-forbidden.html
. If you want to store your objects and your custom error pages in different locations, your distribution must include a cache behavior for which the following is true:
-
The value of
PathPattern
matches the path to your custom error messages. For example, suppose you saved custom error pages for 4xx errors in an Amazon S3 bucket in a directory named/4xx-errors
. Your distribution must include a cache behavior for which the path pattern routes requests for your custom error pages to that location, for example,/4xx-errors/*
. -
The value of
TargetOriginId
specifies the value of theID
element for the origin that contains your custom error pages.
If you specify a value for ResponsePagePath
, you must also specify a value for ResponseCode
.
We recommend that you store custom error pages in an Amazon S3 bucket. If you store custom error pages on an HTTP server and the server starts to return 5xx errors, CloudFront can't get the files that you want to return to viewers because the origin server is unavailable.
sourcepub fn response_code(&self) -> Option<&str>
pub fn response_code(&self) -> Option<&str>
The HTTP status code that you want CloudFront to return to the viewer along with the custom error page. There are a variety of reasons that you might want CloudFront to return a status code different from the status code that your origin returned to CloudFront, for example:
-
Some Internet devices (some firewalls and corporate proxies, for example) intercept HTTP 4xx and 5xx and prevent the response from being returned to the viewer. If you substitute
200
, the response typically won't be intercepted. -
If you don't care about distinguishing among different client errors or server errors, you can specify
400
or500
as theResponseCode
for all 4xx or 5xx errors. -
You might want to return a
200
status code (OK) and static website so your customers don't know that your website is down.
If you specify a value for ResponseCode
, you must also specify a value for ResponsePagePath
.
sourcepub fn error_caching_min_ttl(&self) -> Option<i64>
pub fn error_caching_min_ttl(&self) -> Option<i64>
The minimum amount of time, in seconds, that you want CloudFront to cache the HTTP status code specified in ErrorCode
. When this time period has elapsed, CloudFront queries your origin to see whether the problem that caused the error has been resolved and the requested object is now available.
For more information, see Customizing Error Responses in the Amazon CloudFront Developer Guide.
source§impl CustomErrorResponse
impl CustomErrorResponse
sourcepub fn builder() -> Builder
pub fn builder() -> Builder
Creates a new builder-style object to manufacture CustomErrorResponse
.
Examples found in repository?
14485 14486 14487 14488 14489 14490 14491 14492 14493 14494 14495 14496 14497 14498 14499 14500 14501 14502 14503 14504 14505 14506 14507 14508 14509 14510 14511 14512 14513 14514 14515 14516 14517 14518 14519 14520 14521 14522 14523 14524 14525 14526 14527 14528 14529 14530 14531 14532 14533 14534 14535 14536 14537 14538 14539 14540 14541 14542 14543 14544 14545 14546 14547 14548 14549 14550 14551 14552
pub fn deser_structure_crate_model_custom_error_response(
decoder: &mut aws_smithy_xml::decode::ScopedDecoder,
) -> Result<crate::model::CustomErrorResponse, aws_smithy_xml::decode::XmlDecodeError> {
#[allow(unused_mut)]
let mut builder = crate::model::CustomErrorResponse::builder();
while let Some(mut tag) = decoder.next_tag() {
match tag.start_el() {
s if s.matches("ErrorCode") /* ErrorCode com.amazonaws.cloudfront#CustomErrorResponse$ErrorCode */ => {
let var_619 =
Some(
{
<i32 as aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
)
.map_err(|_|aws_smithy_xml::decode::XmlDecodeError::custom("expected (integer: `com.amazonaws.cloudfront#integer`)"))
}
?
)
;
builder = builder.set_error_code(var_619);
}
,
s if s.matches("ResponsePagePath") /* ResponsePagePath com.amazonaws.cloudfront#CustomErrorResponse$ResponsePagePath */ => {
let var_620 =
Some(
Result::<std::string::String, aws_smithy_xml::decode::XmlDecodeError>::Ok(
aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
.into()
)
?
)
;
builder = builder.set_response_page_path(var_620);
}
,
s if s.matches("ResponseCode") /* ResponseCode com.amazonaws.cloudfront#CustomErrorResponse$ResponseCode */ => {
let var_621 =
Some(
Result::<std::string::String, aws_smithy_xml::decode::XmlDecodeError>::Ok(
aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
.into()
)
?
)
;
builder = builder.set_response_code(var_621);
}
,
s if s.matches("ErrorCachingMinTTL") /* ErrorCachingMinTTL com.amazonaws.cloudfront#CustomErrorResponse$ErrorCachingMinTTL */ => {
let var_622 =
Some(
{
<i64 as aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
)
.map_err(|_|aws_smithy_xml::decode::XmlDecodeError::custom("expected (long: `com.amazonaws.cloudfront#long`)"))
}
?
)
;
builder = builder.set_error_caching_min_ttl(var_622);
}
,
_ => {}
}
}
Ok(builder.build())
}
Trait Implementations§
source§impl Clone for CustomErrorResponse
impl Clone for CustomErrorResponse
source§fn clone(&self) -> CustomErrorResponse
fn clone(&self) -> CustomErrorResponse
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more