v0.42.3
This commit is contained in:
1 parent
a75893d428
commit
bfbeedfad7
43 files changed
+5834
-125
No files matched your search
@@ -26,6 +26,26 @@ pub fn builtin_gateway_error(status: StatusCode) -> Option<&'static str> {
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn cloudflare_style_page(status: StatusCode) -> Option<&'static str> {
|
||||
match status.as_u16() {
|
||||
200 => Some(include_str!("../admin/web/cf_page/error_200.html")),
|
||||
400 => Some(include_str!("../admin/web/cf_page/error_400.html")),
|
||||
401 => Some(include_str!("../admin/web/cf_page/error_401.html")),
|
||||
403 => Some(include_str!("../admin/web/cf_page/error_403.html")),
|
||||
404 => Some(include_str!("../admin/web/cf_page/error_404.html")),
|
||||
408 => Some(include_str!("../admin/web/cf_page/error_408.html")),
|
||||
410 => Some(include_str!("../admin/web/cf_page/error_410.html")),
|
||||
413 => Some(include_str!("../admin/web/cf_page/error_413.html")),
|
||||
429 => Some(include_str!("../admin/web/cf_page/error_429.html")),
|
||||
500 => Some(include_str!("../admin/web/cf_page/error_500.html")),
|
||||
502 => Some(include_str!("../admin/web/cf_page/error_502.html")),
|
||||
503 => Some(include_str!("../admin/web/cf_page/error_503.html")),
|
||||
504 => Some(include_str!("../admin/web/cf_page/error_504.html")),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn builtin_application_page(status: StatusCode) -> String {
|
||||
if status == StatusCode::OK {
|
||||
return include_str!("../admin/web/status_200.html").to_owned();
|
||||
@@ -67,6 +87,7 @@ pub enum Kind {
|
||||
Empty,
|
||||
Html,
|
||||
Builtin,
|
||||
Cloudflare,
|
||||
}
|
||||
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
|
||||
#[serde(default, deny_unknown_fields)]
|
||||
@@ -162,6 +183,9 @@ impl Page {
|
||||
Kind::Html => self.html.clone(),
|
||||
Kind::Welcome => include_str!("../admin/web/demo.html").to_owned(),
|
||||
Kind::Builtin => builtin_application_page(status),
|
||||
Kind::Cloudflare => cloudflare_style_page(status)
|
||||
.map(str::to_owned)
|
||||
.unwrap_or_else(|| builtin_application_page(status)),
|
||||
}
|
||||
}
|
||||
pub fn render(&self, default_status: StatusCode) -> Response {
|
||||
|
||||
Reference in new issue
Block a user