diff options
Diffstat (limited to 'exes/webhook/src')
| -rw-r--r-- | exes/webhook/src/handler/handler.rs | 16 | ||||
| -rw-r--r-- | exes/webhook/src/handler/make_service.rs | 4 | ||||
| -rw-r--r-- | exes/webhook/src/main.rs | 6 |
3 files changed, 12 insertions, 14 deletions
diff --git a/exes/webhook/src/handler/handler.rs b/exes/webhook/src/handler/handler.rs index 3294c22..b2ef44c 100644 --- a/exes/webhook/src/handler/handler.rs +++ b/exes/webhook/src/handler/handler.rs @@ -8,7 +8,7 @@ use hyper::{ Body, Method, Request, Response, StatusCode, }; use serde::{Deserialize, Serialize}; -use shared::nats_crate::Connection; +use shared::nats_crate::Client; use shared::{ log::{debug, error}, payloads::{CachePayload, DispatchEventTagged, Tracing}, @@ -19,7 +19,6 @@ use std::{ str::from_utf8, sync::Arc, task::{Context, Poll}, - time::Duration, }; use twilight_model::gateway::event::{DispatchEvent}; use twilight_model::{ @@ -31,7 +30,7 @@ use twilight_model::{ #[derive(Clone)] pub struct HandlerService { pub config: Arc<Config>, - pub nats: Arc<Connection>, + pub nats: Arc<Client>, pub public_key: Arc<PublicKey>, } @@ -107,14 +106,13 @@ impl HandlerService { let payload = serde_json::to_string(&data).unwrap(); - match self.nats.request_timeout( - "nova.cache.dispatch.INTERACTION_CREATE", - payload, - Duration::from_secs(2), - ) { + match self.nats.request( + "nova.cache.dispatch.INTERACTION_CREATE".to_string(), + Bytes::from(payload), + ).await { Ok(response) => Ok(Response::builder() .header("Content-Type", "application/json") - .body(Body::from(response.data)) + .body(Body::from(response.reply.unwrap())) .unwrap()), Err(error) => { diff --git a/exes/webhook/src/handler/make_service.rs b/exes/webhook/src/handler/make_service.rs index 2774917..48672a1 100644 --- a/exes/webhook/src/handler/make_service.rs +++ b/exes/webhook/src/handler/make_service.rs @@ -1,7 +1,7 @@ use super::handler::HandlerService; use crate::config::Config; use hyper::service::Service; -use shared::nats_crate::Connection; +use shared::nats_crate::Client; use std::{ future::{ready, Ready}, sync::Arc, @@ -11,7 +11,7 @@ use ed25519_dalek::PublicKey; pub struct MakeSvc { pub settings: Arc<Config>, - pub nats: Arc<Connection>, + pub nats: Arc<Client>, pub public_key: Arc<PublicKey> } diff --git a/exes/webhook/src/main.rs b/exes/webhook/src/main.rs index 9527d0f..336dd82 100644 --- a/exes/webhook/src/main.rs +++ b/exes/webhook/src/main.rs @@ -4,10 +4,10 @@ mod handler; use crate::handler::make_service::MakeSvc; use crate::config::Config; -use shared::config::Settings; -use shared::log::{error, info}; use ed25519_dalek::PublicKey; use hyper::Server; +use shared::config::Settings; +use shared::log::{error, info}; #[tokio::main] async fn main() { @@ -35,7 +35,7 @@ async fn start(settings: Settings<Config>) { Arc::new(PublicKey::from_bytes(&hex::decode(&config.discord.public_key).unwrap()).unwrap()); let server = Server::bind(&addr).serve(MakeSvc { settings: config, - nats: Arc::new(settings.nats.into()), + nats: Arc::new(settings.nats.to_client().await.unwrap()), public_key: public_key, }); |
