From b528b77f77893d98bbbf194bb0fd83b7c6fdd18f Mon Sep 17 00:00:00 2001 From: Antoine Gersant Date: Sat, 27 Oct 2018 14:03:56 -0700 Subject: [PATCH] Rocket Hello World --- Cargo.lock | 143 ++++++++++++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 1 + src/main.rs | 10 ++++ 3 files changed, 154 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 6c3509e..03a0471 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -175,6 +175,17 @@ dependencies = [ "url 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "cookie" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "base64 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", + "ring 0.13.2 (registry+https://github.com/rust-lang/crates.io-index)", + "time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", + "url 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "core-foundation" version = "0.2.3" @@ -308,6 +319,35 @@ dependencies = [ "syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "derive_utils" +version = "0.1.0" +source = "git+https://github.com/SergioBenitez/derive-utils?rev=62f361f#62f361fe78b3b19dac5348e1a91c4960ec4dcb60" +dependencies = [ + "derive_utils_codegen 0.1.0 (git+https://github.com/SergioBenitez/derive-utils?rev=62f361f)", + "derive_utils_core 0.1.0 (git+https://github.com/SergioBenitez/derive-utils?rev=62f361f)", +] + +[[package]] +name = "derive_utils_codegen" +version = "0.1.0" +source = "git+https://github.com/SergioBenitez/derive-utils?rev=62f361f#62f361fe78b3b19dac5348e1a91c4960ec4dcb60" +dependencies = [ + "derive_utils_core 0.1.0 (git+https://github.com/SergioBenitez/derive-utils?rev=62f361f)", + "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "derive_utils_core" +version = "0.1.0" +source = "git+https://github.com/SergioBenitez/derive-utils?rev=62f361f#62f361fe78b3b19dac5348e1a91c4960ec4dcb60" +dependencies = [ + "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.14 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "diesel" version = "1.3.3" @@ -724,6 +764,17 @@ dependencies = [ "url 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "isatty" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "itoa" version = "0.4.3" @@ -1326,6 +1377,26 @@ dependencies = [ "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "pear" +version = "0.1.0" +source = "git+http://github.com/SergioBenitez/Pear?rev=00b9af5#00b9af5456932533c876cdb227eb123701b142f6" +dependencies = [ + "pear_codegen 0.1.0 (git+http://github.com/SergioBenitez/Pear?rev=00b9af5)", +] + +[[package]] +name = "pear_codegen" +version = "0.1.0" +source = "git+http://github.com/SergioBenitez/Pear?rev=00b9af5#00b9af5456932533c876cdb227eb123701b142f6" +dependencies = [ + "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.14 (registry+https://github.com/rust-lang/crates.io-index)", + "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "yansi 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "percent-encoding" version = "1.0.1" @@ -1425,6 +1496,7 @@ dependencies = [ "regex 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "reqwest 0.9.4 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.13.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rocket 0.4.0-dev (git+https://github.com/SergioBenitez/Rocket)", "router 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "rusqlite 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", "rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1646,6 +1718,55 @@ dependencies = [ "untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "rocket" +version = "0.4.0-dev" +source = "git+https://github.com/SergioBenitez/Rocket#556206e8b381b07c2c74f64fd88a762f5323fd70" +dependencies = [ + "base64 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", + "isatty 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "pear 0.1.0 (git+http://github.com/SergioBenitez/Pear?rev=00b9af5)", + "rocket_codegen 0.4.0-dev (git+https://github.com/SergioBenitez/Rocket)", + "rocket_http 0.4.0-dev (git+https://github.com/SergioBenitez/Rocket)", + "state 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", + "toml 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "yansi 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rocket_codegen" +version = "0.4.0-dev" +source = "git+https://github.com/SergioBenitez/Rocket#556206e8b381b07c2c74f64fd88a762f5323fd70" +dependencies = [ + "derive_utils 0.1.0 (git+https://github.com/SergioBenitez/derive-utils?rev=62f361f)", + "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", + "rocket_http 0.4.0-dev (git+https://github.com/SergioBenitez/Rocket)", + "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "yansi 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rocket_http" +version = "0.4.0-dev" +source = "git+https://github.com/SergioBenitez/Rocket#556206e8b381b07c2c74f64fd88a762f5323fd70" +dependencies = [ + "cookie 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "hyper 0.10.15 (registry+https://github.com/rust-lang/crates.io-index)", + "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "pear 0.1.0 (git+http://github.com/SergioBenitez/Pear?rev=00b9af5)", + "percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "state 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "route-recognizer" version = "0.1.12" @@ -1928,6 +2049,11 @@ name = "stable_deref_trait" version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "state" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "staticfile" version = "0.5.0" @@ -2516,6 +2642,11 @@ dependencies = [ "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "yansi" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [metadata] "checksum adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7e522997b529f05601e05166c07ed17789691f562762c7f3b987263d2dedee5c" "checksum aho-corasick 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)" = "68f56c7353e5a9547cbd76ed90f7bb5ffc3ba09d4ea9bd1d8c06c8b1142eeb5a" @@ -2540,6 +2671,7 @@ dependencies = [ "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" "checksum color_quant 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0dbbb57365263e881e805dc77d94697c9118fd94d8da011240555aa7b23445bd" "checksum cookie 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "746858cae4eae40fff37e1998320068df317bc247dc91a67c6cfa053afdc2abb" +"checksum cookie 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1465f8134efa296b4c19db34d909637cb2bf0f7aaf21299e23e18fa29ac557cf" "checksum core-foundation 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "25bfd746d203017f7d5cbd31ee5d8e17f94b6521c7af77ece6c9e4b2d4b16c67" "checksum core-foundation 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "286e0b41c3a20da26536c6000a280585d519fd07b3956b43aed8a79e9edce980" "checksum core-foundation-sys 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "065a5d7ffdcbc8fa145d6f0746f3555025b9097a9e9cda59f7467abae670c78d" @@ -2555,6 +2687,9 @@ dependencies = [ "checksum deflate 0.7.19 (registry+https://github.com/rust-lang/crates.io-index)" = "8a6abb26e16e8d419b5c78662aa9f82857c2386a073da266840e474d5055ec86" "checksum derive_builder 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c998e6ab02a828dd9735c18f154e14100e674ed08cb4e1938f0e4177543f439" "checksum derive_builder_core 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "735e24ee9e5fa8e16b86da5007856e97d592e11867e45d76e0c0d0a164a0b757" +"checksum derive_utils 0.1.0 (git+https://github.com/SergioBenitez/derive-utils?rev=62f361f)" = "" +"checksum derive_utils_codegen 0.1.0 (git+https://github.com/SergioBenitez/derive-utils?rev=62f361f)" = "" +"checksum derive_utils_core 0.1.0 (git+https://github.com/SergioBenitez/derive-utils?rev=62f361f)" = "" "checksum diesel 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "164080ac16a4d1d80a50f0a623e4ddef41cb2779eee85bcc76907d340dfc98cc" "checksum diesel_derives 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "03bcaf77491f53e400d5ee3bdd57142ea4e1c47fe9217b3361ff9a76ca0e3d37" "checksum diesel_migrations 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "17b42c35d1ce9e8d57a3e7001b4127f2bc1b073a89708bb7019f5be27c991c28" @@ -2597,6 +2732,7 @@ dependencies = [ "checksum inflate 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6f53b811ee8e2057ccf9643ca6b4277de90efaf5e61e55fd5254576926bb4245" "checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08" "checksum iron 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d8e17268922834707e1c29e8badbf9c712c9c43378e1b6a3388946baff10be2" +"checksum isatty 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e31a8281fc93ec9693494da65fbf28c0c2aa60a2eaec25dc58e2f31952e95edc" "checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b" "checksum jpeg-decoder 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "c8b7d43206b34b3f94ea9445174bda196e772049b9bddbc620c9d29b2d20110d" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" @@ -2663,6 +2799,8 @@ dependencies = [ "checksum params 0.6.0 (git+https://github.com/agersant/params)" = "" "checksum parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f0802bff09003b291ba756dc7e79313e51cc31667e94afbe847def490424cde5" "checksum parking_lot_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ad7f7e6ebdc79edff6fdcb87a55b620174f7a989e3eb31b65231f4af57f00b8c" +"checksum pear 0.1.0 (git+http://github.com/SergioBenitez/Pear?rev=00b9af5)" = "" +"checksum pear_codegen 0.1.0 (git+http://github.com/SergioBenitez/Pear?rev=00b9af5)" = "" "checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" "checksum persistent 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8e8fa0009c4f3d350281309909c618abddf10bb7e3145f28410782f6a5ec74c5" "checksum phf 0.7.23 (registry+https://github.com/rust-lang/crates.io-index)" = "cec29da322b242f4c3098852c77a0ca261c9c01b806cae85a5572a1eb94db9a6" @@ -2692,6 +2830,9 @@ dependencies = [ "checksum reqwest 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "5866613d84e2a39c0479a960bf2d0eff1fbfc934f02cd42b5c08c1e1efc5b1fd" "checksum reqwest 0.9.4 (registry+https://github.com/rust-lang/crates.io-index)" = "00a5870d8edc74fc6e1eb58edbd2815d2243e1a2255d6bf9c82a7a875901b5db" "checksum ring 0.13.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe642b9dd1ba0038d78c4a3999d1ee56178b4d415c1e1fbaba83b06dce012f0" +"checksum rocket 0.4.0-dev (git+https://github.com/SergioBenitez/Rocket)" = "" +"checksum rocket_codegen 0.4.0-dev (git+https://github.com/SergioBenitez/Rocket)" = "" +"checksum rocket_http 0.4.0-dev (git+https://github.com/SergioBenitez/Rocket)" = "" "checksum route-recognizer 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3255338088df8146ba63d60a9b8e3556f1146ce2973bc05a75181a42ce2256" "checksum router 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "dc63b6f3b8895b0d04e816b2b1aa58fdba2d5acca3cbb8f0ab8e017347d57397" "checksum rusqlite 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c9d9118f1ce84d8d0b67f9779936432fb42bb620cef2122409d786892cce9a3c" @@ -2728,6 +2869,7 @@ dependencies = [ "checksum smallvec 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4c8cbcd6df1e117c2210e13ab5109635ad68a929fcbb8964dc965b76cb5ee013" "checksum smallvec 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "153ffa32fd170e9944f7e0838edf824a754ec4c1fc64746fcc9fe1f8fa602e5d" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" +"checksum state 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7345c971d1ef21ffdbd103a75990a15eb03604fc8b8852ca8cb418ee1a099028" "checksum staticfile 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "babd3fa68bb7e3994ce181c5f21ff3ff5fffef7b18b8a10163b45e4dafc6fb86" "checksum string 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "00caf261d6f90f588f8450b8e1230fa0d5be49ee6140fdfbcb55335aff350970" "checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad" @@ -2795,3 +2937,4 @@ dependencies = [ "checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" "checksum xdg 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a66b7c2281ebde13cf4391d70d4c7e5946c3c25e72a7b859ca8f677dcd0b0c61" "checksum xml-rs 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7ec6c39eaa68382c8e31e35239402c0a9489d4141a8ceb0c716099a0b515b562" +"checksum yansi 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d60c3b48c9cdec42fb06b3b84b5b087405e1fa1c644a1af3930e4dfafe93de48" diff --git a/Cargo.toml b/Cargo.toml index eea3287..64dd459 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,6 +30,7 @@ rand = "0.5.5" regex = "1.0.5" ring = "0.13.2" reqwest = "0.9.2" +rocket = { git = "https://github.com/SergioBenitez/Rocket" } router = "0.6.0" rust-crypto = "0.2.36" secure-session = "0.3.1" diff --git a/src/main.rs b/src/main.rs index 4535873..5c0be34 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,5 @@ #![recursion_limit = "256"] +#![feature(proc_macro_hygiene, decl_macro)] extern crate ape; extern crate app_dirs; @@ -26,6 +27,8 @@ extern crate rand; extern crate regex; extern crate reqwest; extern crate ring; +#[macro_use] +extern crate rocket; extern crate router; extern crate rustfm_scrobble; extern crate secure_session; @@ -148,6 +151,11 @@ fn init_log(log_level: LevelFilter, _: &getopts::Matches) -> Result<()> { Ok(()) } +#[get("/")] +fn index() -> &'static str { + "Hello, world!" +} + fn run() -> Result<()> { // Parse CLI options let args: Vec = std::env::args().collect(); @@ -261,6 +269,8 @@ fn run() -> Result<()> { Err(e) => bail!("Error starting up server: {}", e), }; + rocket::ignite().mount("/", routes![index]).launch(); + // Start DDNS updates let db_ref = db.clone(); std::thread::spawn(move || {