add basic book/chapter

This commit is contained in:
Milim 2024-12-07 09:16:01 +01:00
parent f5e7e0a36e
commit 1b98cbac1a
No known key found for this signature in database
2 changed files with 17 additions and 0 deletions

15
src/books/mod.rs Normal file
View file

@ -0,0 +1,15 @@
use actix_web::{get, web, Scope};
pub fn book_scope() -> Scope {
web::scope("/b").service(book_view).service(chapter_view)
}
#[get("/{book}")]
async fn book_view(book: web::Path<String>) -> String {
format!("This is the info for {book}")
}
#[get("/{book}/{chapter})")]
async fn chapter_view(path: web::Path<(String, String)>) -> String {
format!("This is {} of {}", path.0, path.1)
}

View file

@ -1,6 +1,7 @@
use actix_web::{get, App, HttpServer};
use log::info;
mod books;
mod config;
mod db;
@ -16,6 +17,7 @@ async fn main() -> Result<(), std::io::Error> {
App::new()
.app_data(config)
.app_data(db.clone())
.service(books::book_scope())
.service(hello)
})
.bind((config.binding_ip, config.port))?