[Add] Omega Index route
This commit is contained in:
parent
ee3cceb26b
commit
c41860509a
3 changed files with 20 additions and 1 deletions
17
src/server/index.rs
Normal file
17
src/server/index.rs
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
use actix_web::{HttpResponse, Responder};
|
||||||
|
|
||||||
|
pub async fn index_handler() -> impl Responder {
|
||||||
|
let documentation = r#"
|
||||||
|
Omega API Server
|
||||||
|
|
||||||
|
Available Routes:
|
||||||
|
- /api/* : API endpoints for the Omega server.
|
||||||
|
- /direct/* : Resolution for shortened links.
|
||||||
|
|
||||||
|
All other routes will return this documentation.
|
||||||
|
"#;
|
||||||
|
|
||||||
|
HttpResponse::Ok()
|
||||||
|
.content_type("text/plain; charset=utf-8")
|
||||||
|
.body(documentation)
|
||||||
|
}
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
pub mod api;
|
pub mod api;
|
||||||
|
pub mod index;
|
||||||
pub mod server;
|
pub mod server;
|
||||||
pub mod short_link;
|
pub mod short_link;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
log,
|
log,
|
||||||
server::{api, short_link::get_short_link},
|
server::{api, index::index_handler, short_link::get_short_link},
|
||||||
util::file_util::load_file_buf,
|
util::file_util::load_file_buf,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -37,6 +37,7 @@ pub async fn start(port: u16) -> anyhow::Result<()> {
|
||||||
App::new()
|
App::new()
|
||||||
.route("/api/{path:.*}", web::to(api_handler))
|
.route("/api/{path:.*}", web::to(api_handler))
|
||||||
.route("/direct/{path:.*}", web::to(direct_handler))
|
.route("/direct/{path:.*}", web::to(direct_handler))
|
||||||
|
.default_service(web::to(index_handler))
|
||||||
})
|
})
|
||||||
.bind_rustls_0_23(addr, config)?
|
.bind_rustls_0_23(addr, config)?
|
||||||
.run()
|
.run()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue