Add websockets into the api scope

pull/744/head
asonix 2020-04-20 10:25:47 -05:00
parent 217efdd706
commit db4454b52b
3 changed files with 4 additions and 7 deletions

View File

@ -8,7 +8,7 @@ use diesel::r2d2::{ConnectionManager, Pool};
use diesel::PgConnection;
use lemmy_server::{
rate_limit::{rate_limiter::RateLimiter, RateLimit},
routes::{api, federation, feeds, index, nodeinfo, webfinger, websocket},
routes::{api, federation, feeds, index, nodeinfo, webfinger},
settings::Settings,
websocket::server::*,
};
@ -59,7 +59,6 @@ async fn main() -> io::Result<()> {
.configure(index::config)
.configure(nodeinfo::config)
.configure(webfinger::config)
.configure(websocket::config)
// static files
.service(actix_files::Files::new(
"/static",

View File

@ -10,6 +10,8 @@ use actix_web::guard;
pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimit) {
cfg.service(
web::scope("/api/v1")
// Websockets
.service(web::resource("/ws").to(super::websocket::chat_route))
// Site
.service(
web::scope("/site")

View File

@ -2,17 +2,13 @@ use super::*;
use crate::websocket::server::*;
use actix_web::{Error, Result};
pub fn config(cfg: &mut web::ServiceConfig) {
cfg.service(web::resource("/api/v1/ws").to(chat_route));
}
/// How often heartbeat pings are sent
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);
/// Entry point for our route
async fn chat_route(
pub async fn chat_route(
req: HttpRequest,
stream: web::Payload,
chat_server: web::Data<Addr<ChatServer>>,