mirror of
https://github.com/NLnetLabs/krill.git
synced 2026-09-30 13:24:52 +02:00
Introduced house style 404 page
This commit is contained in:
+25
-9
@@ -3,6 +3,8 @@ extern crate rpki_publication_server;
|
||||
extern crate hyper;
|
||||
extern crate futures;
|
||||
|
||||
use std::fs;
|
||||
|
||||
use futures::future;
|
||||
use hyper::{Body, Method, Request, Response, Server, StatusCode};
|
||||
use hyper::rt::Future;
|
||||
@@ -14,19 +16,33 @@ fn service_ok() -> Body {
|
||||
Body::from("I am completely operational, and all my circuits are functioning perfectly.")
|
||||
}
|
||||
|
||||
fn read_static_file(path: &str) -> Body {
|
||||
match path {
|
||||
"/static/css/custom.css" => { Body::from(fs::read("static/css/custom.css").unwrap()) },
|
||||
"/static/images/404.png" => { Body::from(fs::read("static/images/404.png").unwrap()) },
|
||||
"/static/html/404.html" => { Body::from(fs::read("static/html/404.html").unwrap()) },
|
||||
_ => { Body::from("Unknown resource") },
|
||||
}
|
||||
}
|
||||
|
||||
fn request_mapper(req: Request<Body>) -> BoxFut {
|
||||
|
||||
let mut response = Response::new(Body::empty());
|
||||
let path = req.uri().path();
|
||||
|
||||
match (req.method(), req.uri().path()) {
|
||||
(&Method::GET, "/health") => {
|
||||
*response.body_mut() = { service_ok() }
|
||||
},
|
||||
_ => {
|
||||
*response.status_mut() = StatusCode::NOT_FOUND;
|
||||
*response.body_mut() = Body::from("404 - These are not the droids you're looking for.")
|
||||
},
|
||||
};
|
||||
if path.starts_with("/static") {
|
||||
*response.body_mut() = read_static_file(path)
|
||||
} else {
|
||||
match (req.method(), path) {
|
||||
(&Method::GET, "/health") => {
|
||||
*response.body_mut() = { service_ok() }
|
||||
},
|
||||
_ => {
|
||||
*response.status_mut() = StatusCode::NOT_FOUND;
|
||||
*response.body_mut() = read_static_file("/static/html/404.html")
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Box::new(future::ok(response))
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,54 @@
|
||||
<html lang="en" class="fontawesome-i2svg-active fontawesome-i2svg-complete"><head>
|
||||
<title>Not Found!</title>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
<meta name="description" content="Not Found!">
|
||||
<link rel="stylesheet" href="/static/css/custom.css">
|
||||
</head>
|
||||
<body class="ie11-no-flex ">
|
||||
<div class="container p-3 mt-3">
|
||||
<div class="row justify-content-center">
|
||||
<s®ection id="content" class="col main-content">
|
||||
|
||||
<div class="container p-3 mt-3">
|
||||
<div class="row justify-content-center">
|
||||
|
||||
<section id="content" class="col main-content">
|
||||
|
||||
<div class="m-0 p-0 mb-3">
|
||||
<h1><small class="font-weight-bold">THIS IS NOT A 404</small></h1>
|
||||
<div class="border border-black page-title-underbar"></div>
|
||||
</div>
|
||||
<div class="figure align-center">
|
||||
<img alt="This is not a 404." src="/static/images/404.png">
|
||||
<p class="caption"><em>Let's pretend that never happened.</em></p>
|
||||
<div class="legend">
|
||||
Thanks to <a class="reference external" href="https://unsplash.com/@toriamia?utm_medium=referral&utm_campaign=photographer-credit&utm_content=creditBadge">Victoria Palacios</a> for the image.</div>
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<footer id="footer" class="mt-auto pt-3 pb-1 bg-black text-white border-top border-primary">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-12 col-sm-10 mb-3">
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<p>RPKI Publication Server developed by <a href="https://nlnetlabs.nl">NLnet Labs</a></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
</body></html>
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 537 KiB |
Reference in New Issue
Block a user