cargo fmt
This commit is contained in:
@@ -3,13 +3,13 @@ use crate::{
|
|||||||
jsonrpc::{Envelope, RpcClient, RpcClientError, SignalMessage, connect_tcp},
|
jsonrpc::{Envelope, RpcClient, RpcClientError, SignalMessage, connect_tcp},
|
||||||
prometheus::{Prometheus, PrometheusConfig},
|
prometheus::{Prometheus, PrometheusConfig},
|
||||||
};
|
};
|
||||||
use tokio_util::bytes::Buf;
|
|
||||||
use conf::{Conf, Subcommands};
|
use conf::{Conf, Subcommands};
|
||||||
use futures_util::FutureExt;
|
use futures_util::FutureExt;
|
||||||
use http::{Method, Request, Response, StatusCode};
|
use http::{Method, Request, Response, StatusCode};
|
||||||
use http_body::Body;
|
use http_body::Body;
|
||||||
use http_body_util::BodyExt;
|
use http_body_util::BodyExt;
|
||||||
use prometheus_http_client::{AlertStatus, ExtractLabels};
|
use prometheus_http_client::{AlertStatus, ExtractLabels};
|
||||||
|
use tokio_util::bytes::Buf;
|
||||||
//use jsonrpsee::async_client::{Client as JsonRpcClient, Error as JsonRpcError};
|
//use jsonrpsee::async_client::{Client as JsonRpcClient, Error as JsonRpcError};
|
||||||
use chrono::Utc;
|
use chrono::Utc;
|
||||||
use std::{
|
use std::{
|
||||||
@@ -419,15 +419,21 @@ impl Gateway {
|
|||||||
|
|
||||||
match req.uri().path() {
|
match req.uri().path() {
|
||||||
"/" | "/health" | "/ready" => {
|
"/" | "/health" | "/ready" => {
|
||||||
if !matches!(req.method(), Method::GET | Method::HEAD) {
|
if !matches!(req.method(), &Method::GET | &Method::HEAD) {
|
||||||
Ok(err_resp(StatusCode::UNIMPLEMENTED, "Use GET or HEAD with this route"))
|
Ok(err_resp(
|
||||||
|
StatusCode::NOT_IMPLEMENTED,
|
||||||
|
"Use GET or HEAD with this route",
|
||||||
|
))
|
||||||
} else {
|
} else {
|
||||||
Ok(ok_resp())
|
Ok(ok_resp())
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
"/alert" => {
|
"/alert" => {
|
||||||
if !matches!(req.method(), Method::POST) {
|
if !matches!(req.method(), &Method::POST) {
|
||||||
return Ok(err_resp(StatusCode::UNIMPLEMENTED, "Use POST with this route"));
|
return Ok(err_resp(
|
||||||
|
StatusCode::NOT_IMPLEMENTED,
|
||||||
|
"Use POST with this route",
|
||||||
|
));
|
||||||
}
|
}
|
||||||
let v = req
|
let v = req
|
||||||
.into_body()
|
.into_body()
|
||||||
@@ -442,7 +448,7 @@ impl Gateway {
|
|||||||
} else {
|
} else {
|
||||||
Ok(ok_resp())
|
Ok(ok_resp())
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
_ => Ok(err_resp(
|
_ => Ok(err_resp(
|
||||||
StatusCode::NOT_FOUND,
|
StatusCode::NOT_FOUND,
|
||||||
format!("Not found '{} {}'", req.method(), req.uri().path()),
|
format!("Not found '{} {}'", req.method(), req.uri().path()),
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
pub mod alertmanager;
|
pub mod alertmanager;
|
||||||
pub mod gateway;
|
pub mod gateway;
|
||||||
|
|
||||||
pub(crate) mod jsonrpc;
|
|
||||||
pub(crate) mod human_duration;
|
pub(crate) mod human_duration;
|
||||||
|
pub(crate) mod jsonrpc;
|
||||||
pub(crate) mod prometheus;
|
pub(crate) mod prometheus;
|
||||||
pub(crate) mod transports;
|
pub(crate) mod transports;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user