summaryrefslogtreecommitdiff
path: root/src/public
diff options
context:
space:
mode:
Diffstat (limited to 'src/public')
-rw-r--r--src/public/docs.rs10
-rw-r--r--src/public/mod.rs29
-rw-r--r--src/public/pages.rs5
3 files changed, 17 insertions, 27 deletions
diff --git a/src/public/docs.rs b/src/public/docs.rs
index 397e696..7417183 100644
--- a/src/public/docs.rs
+++ b/src/public/docs.rs
@@ -3,7 +3,7 @@ use lazy_static::lazy_static;
use tokio::sync::Mutex;
use crate::{
- api::{admin, auth, posts, users},
+ api::{admin, auth, posts, users, chat},
types::http::ResponseCode,
};
@@ -13,6 +13,7 @@ pub enum EndpointMethod {
Post,
Put,
Patch,
+ Delete
}
impl ToString for EndpointMethod {
@@ -21,6 +22,7 @@ impl ToString for EndpointMethod {
Self::Post => "POST".to_owned(),
Self::Put => "PUT".to_owned(),
Self::Patch => "PATCH".to_owned(),
+ Self::Delete => "DELETE".to_owned(),
}
}
}
@@ -139,6 +141,12 @@ pub async fn init() {
users::USERS_FOLLOW,
users::USERS_FOLLOW_STATUS,
users::USERS_FRIENDS,
+ chat::CHAT_LIST,
+ chat::CHAT_CREATE,
+ chat::CHAT_ADD,
+ chat::CHAT_LEAVE,
+ chat::CHAT_SEND,
+ chat::CHAT_LOAD,
admin::ADMIN_AUTH,
admin::ADMIN_QUERY,
admin::ADMIN_POSTS,
diff --git a/src/public/mod.rs b/src/public/mod.rs
index bb75ef0..bd40fda 100644
--- a/src/public/mod.rs
+++ b/src/public/mod.rs
@@ -1,17 +1,12 @@
use axum::{
body::Body,
- error_handling::HandleErrorLayer,
headers::HeaderName,
http::{HeaderValue, Request, StatusCode},
- response::{IntoResponse, Response},
+ response::{Response, IntoResponse},
routing::get,
- BoxError, Router,
-};
-use tower::{ServiceBuilder, ServiceExt};
-use tower_governor::{
- errors::display_error, governor::GovernorConfigBuilder, key_extractor::SmartIpKeyExtractor,
- GovernorLayer,
+ Router,
};
+use tower::ServiceExt;
use tower_http::services::ServeFile;
use crate::types::http::ResponseCode;
@@ -23,15 +18,6 @@ pub mod file;
pub mod pages;
pub fn router() -> Router {
- let governor_conf = Box::new(
- GovernorConfigBuilder::default()
- .burst_size(30)
- .per_second(1)
- .key_extractor(SmartIpKeyExtractor)
- .finish()
- .expect("Failed to create rate limiter"),
- );
-
Router::new()
.nest("/", pages::router())
.route("/favicon.ico", get(file::favicon))
@@ -42,15 +28,6 @@ pub fn router() -> Router {
.route("/image/*path", get(file::image))
.route("/image/avatar", get(file::avatar))
.route("/image/banner", get(file::banner))
- .layer(
- ServiceBuilder::new()
- .layer(HandleErrorLayer::new(|e: BoxError| async move {
- display_error(e)
- }))
- .layer(GovernorLayer {
- config: Box::leak(governor_conf),
- }),
- )
}
pub async fn serve(path: &str) -> Response {
diff --git a/src/public/pages.rs b/src/public/pages.rs
index a7789b2..0eef51b 100644
--- a/src/public/pages.rs
+++ b/src/public/pages.rs
@@ -66,6 +66,10 @@ async fn forgot(UserAgent(agent): UserAgent, _: Log) -> Response {
Redirect::to("https://www.youtube.com/watch?v=dQw4w9WgXcQ").into_response()
}
+async fn chat() -> Response {
+ super::serve("/chat.html").await
+}
+
pub fn router() -> Router {
Router::new()
.route("/", get(root))
@@ -79,4 +83,5 @@ pub fn router() -> Router {
.route("/admin", get(admin))
.route("/docs", get(api))
.route("/forgot", get(forgot))
+ .route("/chat", get(chat))
}