diff options
author | Tyler Murphy <tylermurphy534@gmail.com> | 2023-02-13 22:41:09 -0500 |
---|---|---|
committer | Tyler Murphy <tylermurphy534@gmail.com> | 2023-02-13 22:41:09 -0500 |
commit | b6fbeb512405542af0aed11ca123b7ac8ee0b04d (patch) | |
tree | 8cd9a708af765c266c6810e78c68ae9003008030 /src/public | |
parent | fix login redirect (diff) | |
download | xssbook-b6fbeb512405542af0aed11ca123b7ac8ee0b04d.tar.gz xssbook-b6fbeb512405542af0aed11ca123b7ac8ee0b04d.tar.bz2 xssbook-b6fbeb512405542af0aed11ca123b7ac8ee0b04d.zip |
fix seo
Diffstat (limited to 'src/public')
-rw-r--r-- | src/public/file.rs | 4 | ||||
-rw-r--r-- | src/public/mod.rs | 3 | ||||
-rw-r--r-- | src/public/pages.rs | 15 |
3 files changed, 18 insertions, 4 deletions
diff --git a/src/public/file.rs b/src/public/file.rs index 88b45b8..b796bc0 100644 --- a/src/public/file.rs +++ b/src/public/file.rs @@ -31,6 +31,10 @@ pub async fn favicon() -> Response { super::serve("/favicon.ico").await } +pub async fn robots() -> Response { + super::serve("/robots.txt").await +} + #[derive(Deserialize)] pub struct AvatarRequest { user_id: u64, diff --git a/src/public/mod.rs b/src/public/mod.rs index 82c994d..76796ea 100644 --- a/src/public/mod.rs +++ b/src/public/mod.rs @@ -35,6 +35,7 @@ pub fn router() -> Router { Router::new() .nest("/", pages::router()) .route("/favicon.ico", get(file::favicon)) + .route("/robots.txt", get(file::robots)) .route("/js/*path", get(file::js)) .route("/css/*path", get(file::css)) .route("/fonts/*path", get(file::fonts)) @@ -71,7 +72,7 @@ pub async fn serve(path: &str) -> Response { res.headers_mut().insert( HeaderName::from_static("cache-control"), - HeaderValue::from_static("public max-age=300"), + HeaderValue::from_static("max-age=300"), ); res.into_response() diff --git a/src/public/pages.rs b/src/public/pages.rs index 32056b7..6d5c0de 100644 --- a/src/public/pages.rs +++ b/src/public/pages.rs @@ -1,13 +1,12 @@ use axum::{ response::{IntoResponse, Redirect, Response}, - routing::get, - Router, + routing::get, Router }; use crate::{ public::console, types::{ - extract::{AuthorizedUser, Log}, + extract::{AuthorizedUser, Log, UserAgent}, http::ResponseCode, }, }; @@ -58,6 +57,15 @@ async fn wordpress(_: Log) -> Response { ResponseCode::ImATeapot.text("Hello i am a teapot owo") } +async fn forgot(UserAgent(agent): UserAgent, _: Log) -> Response { + + if agent.starts_with("curl") { + return super::serve("/404.html").await + } + + Redirect::to("https://www.youtube.com/watch?v=dQw4w9WgXcQ").into_response() +} + pub fn router() -> Router { Router::new() .route("/", get(root)) @@ -69,4 +77,5 @@ pub fn router() -> Router { .route("/wp-admin", get(wordpress)) .route("/admin", get(admin)) .route("/docs", get(api)) + .route("/forgot", get(forgot)) } |