mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-26 22:31:20 +00:00
Add websockets into the api scope
This commit is contained in:
parent
217efdd706
commit
db4454b52b
3 changed files with 4 additions and 7 deletions
|
@ -8,7 +8,7 @@ use diesel::r2d2::{ConnectionManager, Pool};
|
||||||
use diesel::PgConnection;
|
use diesel::PgConnection;
|
||||||
use lemmy_server::{
|
use lemmy_server::{
|
||||||
rate_limit::{rate_limiter::RateLimiter, RateLimit},
|
rate_limit::{rate_limiter::RateLimiter, RateLimit},
|
||||||
routes::{api, federation, feeds, index, nodeinfo, webfinger, websocket},
|
routes::{api, federation, feeds, index, nodeinfo, webfinger},
|
||||||
settings::Settings,
|
settings::Settings,
|
||||||
websocket::server::*,
|
websocket::server::*,
|
||||||
};
|
};
|
||||||
|
@ -59,7 +59,6 @@ async fn main() -> io::Result<()> {
|
||||||
.configure(index::config)
|
.configure(index::config)
|
||||||
.configure(nodeinfo::config)
|
.configure(nodeinfo::config)
|
||||||
.configure(webfinger::config)
|
.configure(webfinger::config)
|
||||||
.configure(websocket::config)
|
|
||||||
// static files
|
// static files
|
||||||
.service(actix_files::Files::new(
|
.service(actix_files::Files::new(
|
||||||
"/static",
|
"/static",
|
||||||
|
|
|
@ -10,6 +10,8 @@ use actix_web::guard;
|
||||||
pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimit) {
|
pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimit) {
|
||||||
cfg.service(
|
cfg.service(
|
||||||
web::scope("/api/v1")
|
web::scope("/api/v1")
|
||||||
|
// Websockets
|
||||||
|
.service(web::resource("/ws").to(super::websocket::chat_route))
|
||||||
// Site
|
// Site
|
||||||
.service(
|
.service(
|
||||||
web::scope("/site")
|
web::scope("/site")
|
||||||
|
|
|
@ -2,17 +2,13 @@ use super::*;
|
||||||
use crate::websocket::server::*;
|
use crate::websocket::server::*;
|
||||||
use actix_web::{Error, Result};
|
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
|
/// How often heartbeat pings are sent
|
||||||
const HEARTBEAT_INTERVAL: Duration = Duration::from_secs(5);
|
const HEARTBEAT_INTERVAL: Duration = Duration::from_secs(5);
|
||||||
/// How long before lack of client response causes a timeout
|
/// How long before lack of client response causes a timeout
|
||||||
const CLIENT_TIMEOUT: Duration = Duration::from_secs(10);
|
const CLIENT_TIMEOUT: Duration = Duration::from_secs(10);
|
||||||
|
|
||||||
/// Entry point for our route
|
/// Entry point for our route
|
||||||
async fn chat_route(
|
pub async fn chat_route(
|
||||||
req: HttpRequest,
|
req: HttpRequest,
|
||||||
stream: web::Payload,
|
stream: web::Payload,
|
||||||
chat_server: web::Data<Addr<ChatServer>>,
|
chat_server: web::Data<Addr<ChatServer>>,
|
||||||
|
|
Loading…
Reference in a new issue