10
10
//! | streamable http | [`streamable_http_client::StreamableHttpClientTransport`] | [`streamable_http_server::StreamableHttpService`] |
11
11
//! | sse | [`sse_client::SseClientTransport`] | [`sse_server::SseServer`] |
12
12
//!
13
- //!## Helper Transport Types
13
+ //! ## Framework Support
14
+ //!
15
+ //! Several transport types support multiple web frameworks through feature flags:
16
+ //!
17
+ //! ### SSE Server Transport
18
+ //! - **Convenience alias**: [`SseServer`] - resolves to the appropriate implementation based on enabled features
19
+ //! - **Explicit types**: [`AxumSseServer`], [`ActixSseServer`] - use specific framework implementations
20
+ //!
21
+ //! ### Streamable HTTP Server Transport
22
+ //! - **Convenience alias**: [`StreamableHttpService`] - resolves to the appropriate implementation based on enabled features
23
+ //! - **Explicit types**: [`AxumStreamableHttpService`], [`ActixStreamableHttpService`] - use specific framework implementations
24
+ //!
25
+ //! #### Type Resolution Strategy
26
+ //! The convenience aliases resolve as follows:
27
+ //! - When `actix-web` feature is enabled: aliases point to actix-web implementations
28
+ //! - When only `axum` feature is enabled: aliases point to axum implementations
29
+ //!
30
+ //! #### Usage Examples
31
+ //! ```rust,ignore
32
+ //! // Using convenience aliases (recommended for most cases)
33
+ //! use rmcp::transport::{SseServer, StreamableHttpService};
34
+ //! let server = SseServer::serve("127.0.0.1:8080".parse()?).await?;
35
+ //!
36
+ //! // Using explicit types (when you need a specific implementation)
37
+ //! #[cfg(feature = "axum")]
38
+ //! use rmcp::transport::AxumSseServer;
39
+ //! #[cfg(feature = "axum")]
40
+ //! let server = AxumSseServer::serve("127.0.0.1:8080".parse()?).await?;
41
+ //! ```
42
+ //!
43
+ //! ## Helper Transport Types
14
44
//! Thers are several helper transport types that can help you to create transport quickly.
15
45
//!
16
46
//! ### [Worker Transport](`worker::WorkerTransport`)
@@ -105,10 +135,21 @@ pub use sse_client::SseClientTransport;
105
135
#[ cfg( feature = "transport-sse-server" ) ]
106
136
#[ cfg_attr( docsrs, doc( cfg( feature = "transport-sse-server" ) ) ) ]
107
137
pub mod sse_server;
108
- #[ cfg( feature = "transport-sse-server" ) ]
109
- #[ cfg_attr( docsrs, doc( cfg( feature = "transport-sse-server" ) ) ) ]
138
+
139
+ // Re-export convenience alias
140
+ #[ cfg( all( feature = "transport-sse-server" , any( feature = "axum" , feature = "actix-web" ) ) ) ]
141
+ #[ cfg_attr( docsrs, doc( cfg( all( feature = "transport-sse-server" , any( feature = "axum" , feature = "actix-web" ) ) ) ) ) ]
110
142
pub use sse_server:: SseServer ;
111
143
144
+ // Re-export explicit types
145
+ #[ cfg( all( feature = "transport-sse-server" , feature = "axum" ) ) ]
146
+ #[ cfg_attr( docsrs, doc( cfg( all( feature = "transport-sse-server" , feature = "axum" ) ) ) ) ]
147
+ pub use sse_server:: AxumSseServer ;
148
+
149
+ #[ cfg( all( feature = "transport-sse-server" , feature = "actix-web" ) ) ]
150
+ #[ cfg_attr( docsrs, doc( cfg( all( feature = "transport-sse-server" , feature = "actix-web" ) ) ) ) ]
151
+ pub use sse_server:: ActixSseServer ;
152
+
112
153
#[ cfg( feature = "auth" ) ]
113
154
#[ cfg_attr( docsrs, doc( cfg( feature = "auth" ) ) ) ]
114
155
pub mod auth;
@@ -122,9 +163,25 @@ pub use auth::{AuthError, AuthorizationManager, AuthorizationSession, Authorized
122
163
#[ cfg( feature = "transport-streamable-http-server-session" ) ]
123
164
#[ cfg_attr( docsrs, doc( cfg( feature = "transport-streamable-http-server-session" ) ) ) ]
124
165
pub mod streamable_http_server;
166
+
167
+ // Re-export configuration
125
168
#[ cfg( feature = "transport-streamable-http-server" ) ]
126
169
#[ cfg_attr( docsrs, doc( cfg( feature = "transport-streamable-http-server" ) ) ) ]
127
- pub use streamable_http_server:: tower:: { StreamableHttpServerConfig , StreamableHttpService } ;
170
+ pub use streamable_http_server:: StreamableHttpServerConfig ;
171
+
172
+ // Re-export the preferred implementation
173
+ #[ cfg( all( feature = "transport-streamable-http-server" , any( feature = "axum" , feature = "actix-web" ) ) ) ]
174
+ #[ cfg_attr( docsrs, doc( cfg( all( feature = "transport-streamable-http-server" , any( feature = "axum" , feature = "actix-web" ) ) ) ) ) ]
175
+ pub use streamable_http_server:: StreamableHttpService ;
176
+
177
+ // Re-export explicit types
178
+ #[ cfg( all( feature = "transport-streamable-http-server" , feature = "axum" ) ) ]
179
+ #[ cfg_attr( docsrs, doc( cfg( all( feature = "transport-streamable-http-server" , feature = "axum" ) ) ) ) ]
180
+ pub use streamable_http_server:: AxumStreamableHttpService ;
181
+
182
+ #[ cfg( all( feature = "transport-streamable-http-server" , feature = "actix-web" ) ) ]
183
+ #[ cfg_attr( docsrs, doc( cfg( all( feature = "transport-streamable-http-server" , feature = "actix-web" ) ) ) ) ]
184
+ pub use streamable_http_server:: ActixStreamableHttpService ;
128
185
129
186
#[ cfg( feature = "transport-streamable-http-client" ) ]
130
187
#[ cfg_attr( docsrs, doc( cfg( feature = "transport-streamable-http-client" ) ) ) ]
0 commit comments