aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin J Hoerr <kjhoerr@protonmail.com>2018-08-29 23:23:21 -0400
committerKevin Hoerr <kjhoerr@submelon.tech>2018-08-31 23:24:45 -0400
commit2463916a5c3f25f3d584aacb8b40130c13619ba1 (patch)
treecc6c44543f85bef121aa8624da695de41e9944f2
parent47d13a8540d0d093a73a81265ede1154ec083911 (diff)
downloadaugust-offensive-2463916a5c3f25f3d584aacb8b40130c13619ba1.tar.gz
august-offensive-2463916a5c3f25f3d584aacb8b40130c13619ba1.tar.bz2
august-offensive-2463916a5c3f25f3d584aacb8b40130c13619ba1.zip
Clean up existing code
-rw-r--r--Cargo.toml1
-rw-r--r--src/routes/messages.rs2
-rw-r--r--src/routes/mod.rs10
3 files changed, 7 insertions, 6 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 4048b54..ee9c89e 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -14,7 +14,6 @@ path = "src/main.rs"
[dependencies]
dotenv = "0.10"
env_logger = "0.5"
-error-chain = "^0.12"
failure = "^0.1"
diesel = { version = "1.3.0", features = ["postgres"] }
diff --git a/src/routes/messages.rs b/src/routes/messages.rs
index 694a2a2..c4d7b5c 100644
--- a/src/routes/messages.rs
+++ b/src/routes/messages.rs
@@ -14,6 +14,6 @@ pub struct Callback {
impl Message for Callback {
fn name(&self) -> String {
- String::from("Callback")
+ String::from("CALLBACK")
}
} \ No newline at end of file
diff --git a/src/routes/mod.rs b/src/routes/mod.rs
index 3d11a8b..ca70dcf 100644
--- a/src/routes/mod.rs
+++ b/src/routes/mod.rs
@@ -9,8 +9,9 @@ pub fn not_understood(_req: &HttpRequest) -> impl Responder {
}
pub fn callback(req: &HttpRequest) -> Result<Json<Callback>> {
- let path = String::from(req.path());
- let request = (*(req.query().deref())).clone();
+ let path = req.path();
+ let query_ref = req.query();
+ let request = query_ref.deref().clone();
Ok(Json(Callback {
path: destruct_path(path),
@@ -18,9 +19,10 @@ pub fn callback(req: &HttpRequest) -> Result<Json<Callback>> {
}))
}
-fn destruct_path(path: String) -> Vec<String> {
+fn destruct_path(path: &str) -> Vec<String> {
path.split_terminator("/")
+ // first element is always blank due to link starting with "/api"
.skip(1)
- .map(|s| String::from(s))
+ .map(String::from)
.collect::<Vec<String>>()
} \ No newline at end of file