From: Matthieu Date: Thu, 14 Oct 2021 21:06:48 +0000 (+0000) Subject: fix gihub ci X-Git-Tag: v0.1~56^2~4 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=8250b77a23b1a4f3102dcb9fe43a745f752462ce;p=matthieu%2Fnova.git fix gihub ci --- diff --git a/gateway/src/shard/connection.rs b/gateway/src/shard/connection.rs index 2f7f2d5..8f8ddc6 100644 --- a/gateway/src/shard/connection.rs +++ b/gateway/src/shard/connection.rs @@ -7,7 +7,7 @@ use crate::{connection::Connection, error::GatewayError, payloads::{ use super::{state::ConnectionState, ConnectionWithState, Shard}; use futures::StreamExt; -use common::{log::{error, info}}; +use common::log::{error, info}; use tokio::{select, time::{Instant, interval_at, sleep}}; impl Shard { diff --git a/webhook/src/handler/handler.rs b/webhook/src/handler/handler.rs index bcce81d..4af2ba6 100644 --- a/webhook/src/handler/handler.rs +++ b/webhook/src/handler/handler.rs @@ -42,39 +42,52 @@ impl HandlerService { ) { Ok(data) } else { - Err(WebhookError::new(StatusCode::UNAUTHORIZED, "invalid signature")) + Err(WebhookError::new( + StatusCode::UNAUTHORIZED, + "invalid signature", + )) } } else { - Err(WebhookError::new(StatusCode::BAD_REQUEST, "failed to read signature")) + Err(WebhookError::new( + StatusCode::BAD_REQUEST, + "failed to read signature", + )) } } else { - Err(WebhookError::new(StatusCode::BAD_REQUEST, "unable to read body")) + Err(WebhookError::new( + StatusCode::BAD_REQUEST, + "unable to read body", + )) } } else { - Err(WebhookError::new(StatusCode::UNAUTHORIZED, "missing signature headers")) + Err(WebhookError::new( + StatusCode::UNAUTHORIZED, + "missing signature headers", + )) } } else { Err(WebhookError::new(StatusCode::NOT_FOUND, "not found")) } } - - async fn process_request(&mut self, req: Request) -> Result, WebhookError> { + async fn process_request( + &mut self, + req: Request, + ) -> Result, WebhookError> { match self.check_request(req).await { Ok(data) => { let utf8 = from_utf8(&data); match utf8 { Ok(data) => match serde_json::from_str::(data) { - Ok(value) => match value.t { - 1 => { + Ok(value) => { + if value.t == 1 { info!("sending pong"); // a ping must be responded with another ping return Ok(Response::builder() .header("Content-Type", "application/json") .body(serde_json::to_string(&Ping { t: 1 }).unwrap().into()) .unwrap()); - } - _ => { + } else { debug!("calling nats"); // this should hopefully not fail ? let payload = @@ -95,20 +108,24 @@ impl HandlerService { ) { Ok(response) => Ok(Response::builder() .header("Content-Type", "application/json") - .body( - Body::from(response.data) - ) + .body(Body::from(response.data)) .unwrap()), - + Err(error) => { error!("failed to request nats: {}", error); - Err(WebhookError::new(StatusCode::INTERNAL_SERVER_ERROR, "failed to request nats")) + Err(WebhookError::new( + StatusCode::INTERNAL_SERVER_ERROR, + "failed to request nats", + )) } } } - }, + } - Err(_) => Err(WebhookError::new(StatusCode::BAD_REQUEST, "invalid json body")), + Err(_) => Err(WebhookError::new( + StatusCode::BAD_REQUEST, + "invalid json body", + )), }, Err(_) => Err(WebhookError::new(StatusCode::BAD_REQUEST, "not utf-8 body")), @@ -142,7 +159,7 @@ impl Service> for HandlerService { match response { Ok(r) => Ok(r), - Err(e) => Ok(e.into()) + Err(e) => Ok(e.into()), } }) }