diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/contrib/admin/site/urls.rs | 8 | ||||
-rw-r--r-- | src/http/mod.rs | 4 | ||||
-rw-r--r-- | src/lib.rs | 5 | ||||
-rw-r--r-- | src/server/mod.rs | 11 | ||||
-rw-r--r-- | src/urls/mod.rs | 17 |
5 files changed, 23 insertions, 22 deletions
diff --git a/src/contrib/admin/site/urls.rs b/src/contrib/admin/site/urls.rs index 5e81c4e..ef23d55 100644 --- a/src/contrib/admin/site/urls.rs +++ b/src/contrib/admin/site/urls.rs @@ -1,3 +1,7 @@ -use crate::urls::Path; +use crate::http::{Filter, Reply}; +use crate::urls::{UrlMap, path}; -pub const URL_PATTERNS: &[Path] = &[]; +pub fn urls() -> UrlMap { + path::end().map(|| Reply::into_response("bruh")) + .boxed() +} diff --git a/src/http/mod.rs b/src/http/mod.rs index 69a0706..f8f1066 100644 --- a/src/http/mod.rs +++ b/src/http/mod.rs @@ -1,3 +1 @@ -pub struct Request {} - -pub struct Response(pub &'static str); +pub use warp::{Filter, Reply, reply::Response}; @@ -1,7 +1,6 @@ pub mod contrib; pub mod http; +pub mod server; pub mod urls; -pub fn run_server(url_patterns: &[urls::Path]) { - todo!(); -} +pub use server::run_server; diff --git a/src/server/mod.rs b/src/server/mod.rs new file mode 100644 index 0000000..b275616 --- /dev/null +++ b/src/server/mod.rs @@ -0,0 +1,11 @@ +use crate::urls::UrlMap; + +pub fn run_server(filter_stack: UrlMap) { + let server_task = warp::serve(filter_stack).run(([127, 0, 0, 1], 3030)); + + tokio::runtime::Builder::new_multi_thread() + .enable_all() + .build() + .unwrap() + .block_on(server_task) +} diff --git a/src/urls/mod.rs b/src/urls/mod.rs index 1acf186..45720b6 100644 --- a/src/urls/mod.rs +++ b/src/urls/mod.rs @@ -1,16 +1,5 @@ -use crate::http::{Request, Response}; +pub use warp::path; -pub type View = fn(Request) -> Response; +use crate::http::Response; -pub enum Path { - View { - url: &'static str, - view: View, - name: &'static str, - }, - - Include { - url: &'static str, - content: &'static [Path], - }, -} +pub type UrlMap = warp::filters::BoxedFilter<(Response,)>; |