From 4da6e42fc135d4cf17a0e1b4648b233b5f1fc479 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Mon, 29 Mar 2021 17:48:37 -0400 Subject: [PATCH] Fix websocket location to /api/vX --- crates/websocket/src/routes.rs | 6 +----- src/api_routes.rs | 4 +++- src/main.rs | 1 - 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/crates/websocket/src/routes.rs b/crates/websocket/src/routes.rs index a240646f..8a487813 100644 --- a/crates/websocket/src/routes.rs +++ b/crates/websocket/src/routes.rs @@ -15,12 +15,8 @@ const HEARTBEAT_INTERVAL: Duration = Duration::from_secs(5); /// How long before lack of client response causes a timeout const CLIENT_TIMEOUT: Duration = Duration::from_secs(10); -pub fn config(cfg: &mut web::ServiceConfig) { - cfg.service(web::resource("/ws").to(chat_route)); -} - /// Entry point for our route -async fn chat_route( +pub async fn chat_route( req: HttpRequest, stream: web::Payload, context: web::Data, diff --git a/src/api_routes.rs b/src/api_routes.rs index 692daedf..e0158c33 100644 --- a/src/api_routes.rs +++ b/src/api_routes.rs @@ -3,12 +3,14 @@ use lemmy_api::Perform; use lemmy_api_common::{comment::*, community::*, person::*, post::*, site::*, websocket::*}; use lemmy_api_crud::PerformCrud; use lemmy_utils::rate_limit::RateLimit; -use lemmy_websocket::LemmyContext; +use lemmy_websocket::{routes::chat_route, LemmyContext}; use serde::Deserialize; pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimit) { cfg.service( web::scope("/api/v3") + // Websocket + .service(web::resource("/ws").to(chat_route)) // Site .service( web::scope("/site") diff --git a/src/main.rs b/src/main.rs index 7f241733..f8838bfb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -91,7 +91,6 @@ async fn main() -> Result<(), LemmyError> { .data(context) // The routes .configure(|cfg| api_routes::config(cfg, &rate_limiter)) - .configure(lemmy_websocket::routes::config) .configure(lemmy_apub::routes::config) .configure(feeds::config) .configure(|cfg| images::config(cfg, &rate_limiter)) -- 2.44.1