Przeglądaj źródła

Create served docs

Lee Morgan 1 miesiąc temu
rodzic
commit
27acdb544a

+ 2 - 0
.gitignore

@@ -2,3 +2,5 @@
 *swp
 *swo
 .env
+documentation.html
+redoc-static.html

+ 2 - 0
src/controllers/mod.rs

@@ -1,3 +1,5 @@
+pub mod other;
+
 pub mod user;
 pub mod webhook;
 pub mod game;

+ 9 - 0
src/controllers/other/documentation.rs

@@ -0,0 +1,9 @@
+use actix_web::{HttpResponse, get};
+
+#[get("/documentation")]
+pub async fn route() -> HttpResponse {
+    let content = include_str!("../../../static/documentation.html");
+    HttpResponse::Ok()
+        .content_type("text/html")
+        .body(content)
+}

+ 1 - 0
src/controllers/other/mod.rs

@@ -0,0 +1 @@
+pub mod documentation;

+ 1 - 0
src/main.rs

@@ -66,6 +66,7 @@ async fn main() -> std::io::Result<()> {
                 })
             )
             .app_data(web::Data::new(pool.clone()))
+            .configure(routes::other::config)
             .configure(routes::user::config)
             .configure(routes::webhook::config)
             .configure(routes::game::game::config)

+ 1 - 0
src/routes/mod.rs

@@ -1,3 +1,4 @@
 pub mod user;
 pub mod webhook;
 pub mod game;
+pub mod other;

+ 8 - 0
src/routes/other.rs

@@ -0,0 +1,8 @@
+use actix_web::web::ServiceConfig;
+use crate::controllers::other::{
+    documentation
+};
+
+pub fn config(cfg: &mut ServiceConfig) {
+    cfg.service(documentation::route);
+}