|
2 | 2 | #![deny(rust_2018_idioms)]
|
3 | 3 |
|
4 | 4 | use hyper::service::{make_service_fn, service_fn};
|
5 |
| -use hyper::{Body, Error, Request, Response, Server, StatusCode, Method}; |
| 5 | +use hyper::{Body, Error, Method, Request, Response, Server, StatusCode}; |
6 | 6 | use primitives::adapter::Adapter;
|
7 | 7 | use primitives::Config;
|
8 | 8 | use slog::{error, info, Logger};
|
9 | 9 |
|
10 | 10 | pub mod routes {
|
11 | 11 | pub mod channel;
|
12 | 12 | pub mod cfg {
|
13 |
| - use hyper::{Body, Response}; |
14 | 13 | use crate::ResponseError;
|
| 14 | + use hyper::{Body, Response}; |
15 | 15 | use primitives::Config;
|
16 | 16 |
|
17 | 17 | pub fn return_config(config: &Config) -> Result<Response<Body>, ResponseError> {
|
@@ -82,10 +82,13 @@ where
|
82 | 82 | }
|
83 | 83 | }
|
84 | 84 |
|
85 |
| -async fn handle_routing(req: Request<Body>, (adapter, config): (impl Adapter, Config)) -> Response<Body> { |
| 85 | +async fn handle_routing( |
| 86 | + req: Request<Body>, |
| 87 | + (adapter, config): (impl Adapter, Config), |
| 88 | +) -> Response<Body> { |
86 | 89 | if req.uri().path().starts_with("/cfg") && req.method() == Method::GET {
|
87 | 90 | crate::routes::cfg::return_config(&config)
|
88 |
| - }else if req.uri().path().starts_with("/channel") { |
| 91 | + } else if req.uri().path().starts_with("/channel") { |
89 | 92 | crate::routes::channel::handle_channel_routes(req, adapter).await
|
90 | 93 | } else {
|
91 | 94 | Err(ResponseError::NotFound)
|
|
0 commit comments