Skip to content

Commit

Permalink
feat(api_server): add websocket v2 api
Browse files Browse the repository at this point in the history
  • Loading branch information
spacemeowx2 committed Feb 1, 2025
1 parent d04145d commit a3eef25
Show file tree
Hide file tree
Showing 6 changed files with 358 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ async-stream = "0.3.0"
once_cell = "1.7.2"

axum = { version = "0.6.19", features = ["ws"], optional = true }
jsonrpc-core = { version = "18.0.0", optional = true }
serde_urlencoded = { version = "0.7.1", optional = true }
tower-http = { version = "0.4.3", features = [
"fs",
Expand Down Expand Up @@ -92,6 +93,7 @@ rusty-hook = "0.11.0"
default = ["ss", "trojan", "rpc", "obfs", "api_server", "rhai", "raw"]
api_server = [
"axum",
"jsonrpc-core",
"serde_urlencoded",
"tower-http",
"json-patch",
Expand Down
1 change: 1 addition & 0 deletions src/api_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use crate::config::ConfigManager;

mod handlers;
mod routes;
pub mod v2;

pub struct ApiServer {
pub rabbit_digger: RabbitDigger,
Expand Down
2 changes: 2 additions & 0 deletions src/api_server/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use crate::storage::{FileStorage, FolderType};

use super::{
handlers::{self, Ctx},
v2::handlers as v2_handlers,
ApiServer,
};

Expand Down Expand Up @@ -76,6 +77,7 @@ impl ApiServer {
.route("/userdata", get(handlers::list_userdata))
.route("/stream/connection", get(handlers::get_connection))
.route("/stream/logs", get(handlers::ws_log))
.route("/v2/ws", get(v2_handlers::websocket_handler))
.layer(Extension(ctx));

if let Some(token) = &self.access_token {
Expand Down
Loading

0 comments on commit a3eef25

Please sign in to comment.