Skip to content

Commit f55119b

Browse files
committed
Fix: proper formatting
1 parent e7c7ae1 commit f55119b

File tree

2 files changed

+25
-17
lines changed

2 files changed

+25
-17
lines changed

sentry/src/lib.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ impl<A: Adapter + 'static> Application<A> {
106106
return map_response_error(ResponseError::BadRequest("invalid auth".into()));
107107
}
108108
};
109-
109+
110110
let mut response = match (req.uri().path(), req.method()) {
111111
("/cfg", &Method::GET) => config(req, &self).await,
112112
("/channel", &Method::POST) => create_channel(req, &self).await,
@@ -187,7 +187,9 @@ pub fn bad_response(response_body: String) -> Response<Body> {
187187
let body = Body::from(serde_json::to_string(&error_response).expect("serialise err response"));
188188

189189
let mut response = Response::new(body);
190-
response.headers_mut().insert("Content-type", "application/json".parse().unwrap());
190+
response
191+
.headers_mut()
192+
.insert("Content-type", "application/json".parse().unwrap());
191193

192194
let status = response.status_mut();
193195
*status = StatusCode::BAD_REQUEST;
@@ -199,7 +201,9 @@ pub fn success_response(response_body: String) -> Response<Body> {
199201
let body = Body::from(response_body);
200202

201203
let mut response = Response::new(body);
202-
response.headers_mut().insert("Content-type", "application/json".parse().unwrap());
204+
response
205+
.headers_mut()
206+
.insert("Content-type", "application/json".parse().unwrap());
203207

204208
let status = response.status_mut();
205209
*status = StatusCode::OK;

sentry/src/routes/channel.rs

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
use self::channel_list::ChannelListQuery;
22
use crate::middleware::channel::get_channel;
3+
use crate::success_response;
34
use crate::Application;
45
use crate::ResponseError;
56
use crate::RouteParams;
67
use futures::TryStreamExt;
78
use hex::FromHex;
89
use hyper::{Body, Request, Response};
910
use primitives::adapter::Adapter;
11+
use primitives::sentry::SuccessResponse;
1012
use primitives::{Channel, ChannelId};
11-
use primitives::sentry::{SuccessResponse};
12-
use slog::{error};
13-
use crate::success_response;
13+
use slog::error;
1414

15-
pub async fn create_channel<A: Adapter>(req: Request<Body>, app: &Application<A>) -> Result<Response<Body>, ResponseError> {
15+
pub async fn create_channel<A: Adapter>(
16+
req: Request<Body>,
17+
app: &Application<A>,
18+
) -> Result<Response<Body>, ResponseError> {
1619
let body = req.into_body().try_concat().await?;
1720

1821
let channel = serde_json::from_slice::<Channel>(&body)?;
@@ -37,15 +40,15 @@ pub async fn create_channel<A: Adapter>(req: Request<Body>, app: &Application<A>
3740
}
3841
})
3942
.await;
40-
43+
4144
if let Err(err) = result {
4245
error!(&app.logger, "{}", &err; "module" => "create_channel");
43-
return Err(ResponseError::BadRequest("err occured; please try again later".into()));
46+
return Err(ResponseError::BadRequest(
47+
"err occured; please try again later".into(),
48+
));
4449
}
45-
46-
let create_response = SuccessResponse {
47-
success: true,
48-
};
50+
51+
let create_response = SuccessResponse { success: true };
4952

5053
Ok(success_response(serde_json::to_string(&create_response)?))
5154
}
@@ -54,16 +57,18 @@ pub async fn channel_list(req: Request<Body>) -> Result<Response<Body>, Response
5457
// @TODO: Get from Config
5558
let _channel_find_limit = 5;
5659

57-
let query =
58-
serde_urlencoded::from_str::<ChannelListQuery>(&req.uri().query().unwrap_or(""))?;
60+
let query = serde_urlencoded::from_str::<ChannelListQuery>(&req.uri().query().unwrap_or(""))?;
5961

6062
// @TODO: List all channels returned from the DB
6163
println!("{:?}", query);
6264

6365
Err(ResponseError::NotFound)
6466
}
6567

66-
pub async fn last_approved<A: Adapter>(req: Request<Body>, app: &Application<A>) -> Result<Response<Body>, ResponseError> {
68+
pub async fn last_approved<A: Adapter>(
69+
req: Request<Body>,
70+
app: &Application<A>,
71+
) -> Result<Response<Body>, ResponseError> {
6772
// get request params
6873
let route_params = req
6974
.extensions()
@@ -78,7 +83,6 @@ pub async fn last_approved<A: Adapter>(req: Request<Body>, app: &Application<A>)
7883
.unwrap())
7984
}
8085

81-
8286
mod channel_list {
8387
use chrono::{DateTime, Utc};
8488
use serde::{Deserialize, Deserializer};

0 commit comments

Comments
 (0)