mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-26 07:52:13 +00:00
Add websockets into the api scope
This commit is contained in:
parent
217efdd706
commit
db4454b52b
|
@ -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",
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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>>,
|
||||
|
|
Loading…
Reference in a new issue