From c347e5333f44297189dbd804c0d43d60e5efa970 Mon Sep 17 00:00:00 2001 From: moparisthebest Date: Sat, 16 Feb 2019 23:47:09 -0500 Subject: [PATCH] Upgrade to rocket 0.4.0, disable multipart upload --- Cargo.toml | 15 +++++++-------- src/main.rs | 22 ++++++++++++---------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 6125d24..69f1636 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,12 +4,11 @@ version = "0.0.0" publish = false [dependencies] -rocket = "0.3.14" -rocket_codegen = "0.3.14" -rand = "0.4" -multipart = "0.15.2" -toml = "0.4.6" -serde_derive = "1.0.71" -serde = "1.0.71" +rocket = "0.4.0" +rand = "0.6.5" +#multipart = "0.16.1" +toml = "0.4.10" +serde = "1.0.88" +serde_derive = "1.0.88" adjective_adjective_animal = "0.1.0" -#syntect = "2.1.0" \ No newline at end of file +#syntect = "2.1.0" diff --git a/src/main.rs b/src/main.rs index fe65052..5c1f65c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,15 +1,15 @@ -#![feature(plugin, decl_macro, custom_derive)] -#![plugin(rocket_codegen)] +#![feature(proc_macro_hygiene, decl_macro)] +#[macro_use] extern crate rocket; extern crate adjective_adjective_animal; -extern crate multipart; +//extern crate multipart; extern crate toml; #[macro_use] extern crate serde_derive; mod paste_id; -mod mpu; +//mod mpu; #[cfg(test)] mod tests; use std::io; @@ -28,7 +28,7 @@ use rocket::request::{self, Request, FromRequest, State, LenientForm}; use rocket::outcome::Outcome::*; use paste_id::PasteID; -use mpu::MultipartUpload; +//use mpu::MultipartUpload; const HOST: &'static str = "http://localhost:8000"; @@ -139,7 +139,7 @@ trait Backend: Sync + Send { fn upload(&self, paste: Data, _key: Option) -> Result; - fn upload_multipart(&self, paste: MultipartUpload) -> Result; +// fn upload_multipart(&self, paste: MultipartUpload) -> Result; fn upload_string(&self, paste: &PasteForm) -> Result; @@ -180,14 +180,14 @@ impl Backend for DefaultBackend { paste.stream_to_file(Path::new(&filename))?; Ok(url) } - +/* fn upload_multipart(&self, paste: MultipartUpload) -> Result { let (filename, info_filename, url) = self.new_paste(); PasteInfo::default().write(info_filename)?; paste.stream_to_file(Path::new(&filename))?; Ok(url) } - +*/ fn upload_string(&self, paste: &PasteForm) -> Result { let (filename, info_filename, url) = self.new_paste(); PasteInfo::from(paste).write(info_filename)?; @@ -265,14 +265,16 @@ impl<'a> From<&'a PasteForm> for PasteInfo<'a> { // todo: change /w to /, shouldn't conflict because of format, but it does currently #[post("/w", format = "application/x-www-form-urlencoded", data = "")] fn web_post(backend: &Backend, paste: LenientForm) -> Result { - backend.upload_string(paste.get()) + backend.upload_string(&paste.into_inner()) } +/* // todo: change /w to /, shouldn't conflict because of format, but it does currently #[post("/m", format = "multipart/form-data", data = "")] fn mpu_post(backend: &Backend, paste: MultipartUpload) -> Result { backend.upload_multipart(paste) } +*/ #[put("/", data = "")] fn upload_put(backend: &Backend, paste: Data) -> Result { @@ -330,7 +332,7 @@ fn rocket() -> rocket::Rocket { rocket::ignite().mount("/", routes![ index, files, web_post, - mpu_post, +// mpu_post, upload_post, upload_put, upload_patch, upload_post_key, upload_put_key, upload_patch_key, get, delete