Created
December 26, 2018 13:00
-
-
Save dru/7e29eec44230aa6d455d1c52881116eb to your computer and use it in GitHub Desktop.
Minimal upload server on Rust 2018
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[package] | |
name = "server" | |
version = "0.1.0" | |
edition = "2018" | |
[dependencies] | |
rocket = "^0.4.0" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[global.limits] | |
forms = 314572800 | |
[global] | |
address = "0.0.0.0" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![feature(proc_macro_hygiene, decl_macro)] | |
#[cfg(test)] mod tests; | |
use rocket::{routes, post, Data}; | |
use std::io; | |
#[post("/upload", data = "<data>")] | |
fn upload(data: Data) -> io::Result<String> { | |
data.stream_to_file("upload.data").map(|n| n.to_string()) | |
} | |
fn main() { | |
rocket::ignite().mount("/", routes![upload]).launch(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment