1
1
use self :: channel_list:: ChannelListQuery ;
2
2
use crate :: middleware:: channel:: get_channel;
3
+ use crate :: success_response;
3
4
use crate :: Application ;
4
5
use crate :: ResponseError ;
5
6
use crate :: RouteParams ;
6
7
use futures:: TryStreamExt ;
7
8
use hex:: FromHex ;
8
9
use hyper:: { Body , Request , Response } ;
9
10
use primitives:: adapter:: Adapter ;
11
+ use primitives:: sentry:: SuccessResponse ;
10
12
use primitives:: { Channel , ChannelId } ;
11
- use primitives:: sentry:: { SuccessResponse } ;
12
- use slog:: { error} ;
13
- use crate :: success_response;
13
+ use slog:: error;
14
14
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 > {
16
19
let body = req. into_body ( ) . try_concat ( ) . await ?;
17
20
18
21
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>
37
40
}
38
41
} )
39
42
. await ;
40
-
43
+
41
44
if let Err ( err) = result {
42
45
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
+ ) ) ;
44
49
}
45
-
46
- let create_response = SuccessResponse {
47
- success : true ,
48
- } ;
50
+
51
+ let create_response = SuccessResponse { success : true } ;
49
52
50
53
Ok ( success_response ( serde_json:: to_string ( & create_response) ?) )
51
54
}
@@ -54,16 +57,18 @@ pub async fn channel_list(req: Request<Body>) -> Result<Response<Body>, Response
54
57
// @TODO: Get from Config
55
58
let _channel_find_limit = 5 ;
56
59
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 ( "" ) ) ?;
59
61
60
62
// @TODO: List all channels returned from the DB
61
63
println ! ( "{:?}" , query) ;
62
64
63
65
Err ( ResponseError :: NotFound )
64
66
}
65
67
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 > {
67
72
// get request params
68
73
let route_params = req
69
74
. extensions ( )
@@ -78,7 +83,6 @@ pub async fn last_approved<A: Adapter>(req: Request<Body>, app: &Application<A>)
78
83
. unwrap ( ) )
79
84
}
80
85
81
-
82
86
mod channel_list {
83
87
use chrono:: { DateTime , Utc } ;
84
88
use serde:: { Deserialize , Deserializer } ;
0 commit comments