From 059eed6ffa3a0ade449dfc5f5a7a97699e24394e Mon Sep 17 00:00:00 2001 From: hozan23 Date: Mon, 20 May 2024 00:14:15 +0200 Subject: jsonrpc: add ws cargo features --- jsonrpc/src/server.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'jsonrpc/src/server.rs') diff --git a/jsonrpc/src/server.rs b/jsonrpc/src/server.rs index 1cc7e1f..2155295 100644 --- a/jsonrpc/src/server.rs +++ b/jsonrpc/src/server.rs @@ -12,10 +12,10 @@ use karyon_core::async_util::{TaskGroup, TaskResult}; use karyon_net::{Conn, Endpoint, Listener, ToEndpoint}; -use crate::{ - codec::{JsonCodec, WsJsonCodec}, - message, Error, RPCService, Result, -}; +#[cfg(feature = "ws")] +use crate::codec::WsJsonCodec; + +use crate::{codec::JsonCodec, message, Error, RPCService, Result}; pub const INVALID_REQUEST_ERROR_MSG: &str = "Invalid request"; pub const FAILED_TO_PARSE_ERROR_MSG: &str = "Failed to parse"; @@ -230,6 +230,7 @@ impl ServerBuilder { .await?, ), }, + #[cfg(feature = "ws")] Endpoint::Ws(..) | Endpoint::Wss(..) => match &self.tls_config { Some(conf) => Box::new( karyon_net::ws::listen( @@ -249,6 +250,7 @@ impl ServerBuilder { .await?, ), }, + #[cfg(all(feature = "unix", target_family = "unix"))] Endpoint::Unix(..) => Box::new(karyon_net::unix::listen( &self.endpoint, Default::default(), -- cgit v1.2.3