about summary refs log tree commit diff
path: root/src/media/mod.rs
diff options
context:
space:
mode:
authorVika <vika@fireburn.ru>2022-05-24 17:18:30 +0300
committerVika <vika@fireburn.ru>2022-05-24 17:18:30 +0300
commit5610a5f0bf1a9df02bd3d5b55e2cdebef2440360 (patch)
tree8394bcf1dcc204043d7adeb8dde2e2746977606e /src/media/mod.rs
parent2f93873122b47e42f7ee1c38f1f04d052a63599c (diff)
downloadkittybox-5610a5f0bf1a9df02bd3d5b55e2cdebef2440360.tar.zst
flake.nix: reorganize
 - Kittybox's source code is moved to a subfolder
   - This improves build caching by Nix since it doesn't take changes
     to other files into account
 - Package and test definitions were spun into separate files
   - This makes my flake.nix much easier to navigate
   - This also makes it somewhat possible to use without flakes (but
     it is still not easy, so use flakes!)
 - Some attributes were moved in compliance with Nix 2.8's changes to
   flake schema
Diffstat (limited to 'src/media/mod.rs')
-rw-r--r--src/media/mod.rs46
1 files changed, 0 insertions, 46 deletions
diff --git a/src/media/mod.rs b/src/media/mod.rs
deleted file mode 100644
index 0d46e0c..0000000
--- a/src/media/mod.rs
+++ /dev/null
@@ -1,46 +0,0 @@
-use futures_util::StreamExt;
-use bytes::buf::Buf;
-use warp::{Filter, Rejection, Reply, multipart::{FormData, Part}};
-
-pub fn query() -> impl Filter<Extract = (impl Reply,), Error = Rejection> + Clone {
-    warp::get()
-        .and(crate::util::require_host())
-        .map(|host| "media endpoint query...")
-}
-
-pub fn options() -> impl Filter<Extract = (impl Reply,), Error = Rejection> + Clone {
-    warp::options()
-        .map(|| warp::reply::json::<Option<()>>(&None))
-        .with(warp::reply::with::header("Allow", "GET, POST"))
-}
-
-pub fn upload() -> impl Filter<Extract = (impl Reply,), Error = Rejection> + Clone {
-    warp::post()
-        .and(crate::util::require_host())
-        .and(warp::multipart::form().max_length(1024*1024*150/*mb*/))
-        .and_then(|host, mut form: FormData| async move {
-            // TODO get rid of the double unwrap() here
-            let file: Part = form.next().await.unwrap().unwrap();
-            log::debug!("Uploaded: {:?}, type: {:?}", file.filename(), file.content_type());
-
-            let mut data = file.stream();
-            while let Some(buf) = data.next().await {
-                // TODO save it into a file
-                log::debug!("buffer length: {:?}", buf.map(|b| b.remaining()));
-            }
-            Ok::<_, warp::Rejection>(warp::reply::with_header(
-                warp::reply::with_status(
-                    "",
-                    warp::http::StatusCode::CREATED
-                ),
-                "Location",
-                "./awoo.png"
-            ))
-        })
-}
-
-pub fn media() -> impl Filter<Extract = (impl Reply,), Error = Rejection> + Clone {
-    upload()
-        .or(query())
-        .or(options())
-}