Error Page

This commit is contained in:
spikecodes 2020-12-31 21:03:44 -08:00
parent bc1b29246d
commit 39ba50dada
6 changed files with 31 additions and 40 deletions

View file

@ -42,9 +42,10 @@ async fn main() -> std::io::Result<()> {
HttpServer::new(|| {
App::new()
// .default_service(web::get().to(subreddit::page))
// TRAILING SLASH MIDDLEWARE
.wrap(NormalizePath::default())
// DEFAULT SERVICE
.default_service(web::get().to(utils::error))
// GENERAL SERVICES
.route("/style.css/", web::get().to(style))
.route("/favicon.ico/", web::get().to(|| HttpResponse::Ok()))
@ -52,14 +53,16 @@ async fn main() -> std::io::Result<()> {
// PROXY SERVICE
.route("/proxy/{url:.*}/", web::get().to(proxy::handler))
// SEARCH SERVICES
.route("/search/", web::get().to(search::page))
.route("r/{sub}/search/", web::get().to(search::page))
.route("/search/", web::get().to(search::find))
.route("r/{sub}/search/", web::get().to(search::find))
// USER SERVICES
.route("/u/{username}/", web::get().to(user::profile))
.route("/user/{username}/", web::get().to(user::profile))
// SUBREDDIT SERVICES
.route("/r/{sub}/", web::get().to(subreddit::page))
.route("/r/{sub}/{sort}/", web::get().to(subreddit::page))
// WIKI SERVICES
// .route("/r/{sub}/wiki/index", web::get().to(subreddit::wiki))
// POPULAR SERVICES
.route("/", web::get().to(subreddit::page))
.route("/{sort:best|hot|new|top|rising}/", web::get().to(subreddit::page))