refactor: migration to library

This commit is contained in:
2025-01-06 00:33:08 +01:00
parent 2b2707d608
commit e006b8dd12
6 changed files with 44 additions and 4 deletions

View File

@@ -1,5 +1,27 @@
use std::collections::HashMap;
/*
* App types
* */
pub struct HttpAppConfig {
port: u8,
}
pub type HttpAppRouteFunction = Box<dyn Fn(HttpRequest) -> String>;
pub struct HttpAppRoute<'a> {
route: &'a str,
action: HttpAppRouteFunction,
}
pub struct HttpApp<'a> {
config: HttpAppConfig,
routes: Vec<HttpAppRoute<'a>>,
}
/*
* Parser types
* */
// TODO:
// - we could complement status with a struct that stores the status and the error message.
// - an alternative is to have a status-error_mesage mapper in order to send an error explanation to the client