master
rasul 5 years ago
parent f115e72dad
commit 5401bcc268

@ -43,11 +43,13 @@ impl Paste {
lang: "Plain Text".into(),
})
} else {
Err(Box::new(Error::new(ErrorKind::Other, "couldn't generate hash")))
Err(Box::new(Error::new(
ErrorKind::Other,
"couldn't generate hash",
)))
}
}
pub fn from_form(form: HashMap<String, String>, salt: String) -> Result<Self> {
let dt = Utc::now();
let harsh = HarshBuilder::new().salt(salt).init()?;

@ -27,19 +27,14 @@ pub fn get(mut state: State) -> Box<HandlerFuture> {
match Paste::from_file(path) {
Ok(paste) => {
let res = create_response(
&state,
StatusCode::OK,
mime::TEXT_PLAIN,
paste.text,
);
let res = create_response(&state, StatusCode::OK, mime::TEXT_PLAIN, paste.text);
future::ok((state, res))
},
}
Err(e) => {
let io_error = std::io::Error::new(std::io::ErrorKind::Other, e.description());
future::err((state, io_error.into_handler_error()))
},
}
}
})
}

@ -43,20 +43,19 @@ pub fn put(mut state: State) -> Box<HandlerFuture> {
future::ok((state, res))
}
},
}
Err(e) => {
let err = Error::new(ErrorKind::Other, e.description());
future::err((state, err.into_handler_error()))
}
}
},
}
Err(e) => future::err((state, e.into_handler_error())),
}
})
})
}
pub fn post(mut state: State) -> Box<HandlerFuture> {
Box::new({
Body::take_from(&mut state).concat2().then(|body| {
@ -86,12 +85,7 @@ pub fn post(mut state: State) -> Box<HandlerFuture> {
future::ok((state, res))
} else {
let res = create_response(
&state,
StatusCode::OK,
mime::TEXT_PLAIN,
"ERR"
);
let res = create_response(&state, StatusCode::OK, mime::TEXT_PLAIN, "ERR");
future::ok((state, res))
}

@ -8,7 +8,7 @@ lazy_static! {
let mut syntaxes: Vec<String> = Vec::new();
for syntax in syntax_set.syntaxes() {
if ! syntax.hidden {
if !syntax.hidden {
syntaxes.push(syntax.name.clone());
}
}

Loading…
Cancel
Save