aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMelody Horn / boringcactus <melody@boringcactus.com>2021-06-12 23:24:33 -0600
committerMelody Horn / boringcactus <melody@boringcactus.com>2021-06-12 23:24:33 -0600
commit4c8940569e5729213b7eee6f3d5be39b745b697b (patch)
tree20935676f7a14ad12752ec98b65db9f067fba239 /src
parent582124d59afa438e2cb88cc024d6b19232236e1e (diff)
downloadtosin-4c8940569e5729213b7eee6f3d5be39b745b697b.tar.gz
tosin-4c8940569e5729213b7eee6f3d5be39b745b697b.zip
actually implement the easy example
Diffstat (limited to 'src')
-rw-r--r--src/contrib/admin/site/urls.rs8
-rw-r--r--src/http/mod.rs4
-rw-r--r--src/lib.rs5
-rw-r--r--src/server/mod.rs11
-rw-r--r--src/urls/mod.rs17
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};
diff --git a/src/lib.rs b/src/lib.rs
index 28e6ab9..b9cf73d 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -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,)>;