mirror of
https://gitlab.com/famedly/conduit.git
synced 2024-11-04 16:18:51 +01:00
Generalize RumaHandler
This commit is contained in:
parent
d1d2217019
commit
a5757ab195
1 changed files with 7 additions and 7 deletions
14
src/main.rs
14
src/main.rs
|
@ -12,6 +12,7 @@ use std::{future::Future, net::SocketAddr, sync::Arc, time::Duration};
|
||||||
use axum::{
|
use axum::{
|
||||||
extract::{FromRequest, MatchedPath},
|
extract::{FromRequest, MatchedPath},
|
||||||
handler::Handler,
|
handler::Handler,
|
||||||
|
response::IntoResponse,
|
||||||
routing::{get, on, MethodFilter},
|
routing::{get, on, MethodFilter},
|
||||||
Router,
|
Router,
|
||||||
};
|
};
|
||||||
|
@ -256,10 +257,7 @@ fn routes() -> Router {
|
||||||
.ruma_route(client_server::get_state_events_route)
|
.ruma_route(client_server::get_state_events_route)
|
||||||
.ruma_route(client_server::get_state_events_for_key_route)
|
.ruma_route(client_server::get_state_events_for_key_route)
|
||||||
.ruma_route(client_server::get_state_events_for_empty_key_route)
|
.ruma_route(client_server::get_state_events_for_empty_key_route)
|
||||||
.route(
|
.ruma_route(client_server::sync_events_route)
|
||||||
"/_matrix/client/r0/sync",
|
|
||||||
get(client_server::sync_events_route),
|
|
||||||
)
|
|
||||||
.ruma_route(client_server::get_context_route)
|
.ruma_route(client_server::get_context_route)
|
||||||
.ruma_route(client_server::get_message_events_route)
|
.ruma_route(client_server::get_message_events_route)
|
||||||
.ruma_route(client_server::search_events_route)
|
.ruma_route(client_server::search_events_route)
|
||||||
|
@ -375,14 +373,16 @@ macro_rules! impl_ruma_handler {
|
||||||
( $($ty:ident),* $(,)? ) => {
|
( $($ty:ident),* $(,)? ) => {
|
||||||
#[axum::async_trait]
|
#[axum::async_trait]
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
impl<Req, F, Fut, $($ty,)*> RumaHandler<($($ty,)* Ruma<Req>,)> for F
|
impl<Req, E, F, Fut, $($ty,)*> RumaHandler<($($ty,)* Ruma<Req>,)> for F
|
||||||
where
|
where
|
||||||
Req: Outgoing,
|
Req: Outgoing,
|
||||||
Req::Incoming: IncomingRequest + Send,
|
Req::Incoming: IncomingRequest + Send,
|
||||||
F: FnOnce($($ty,)* Ruma<Req>) -> Fut + Clone + Send + 'static,
|
F: FnOnce($($ty,)* Ruma<Req>) -> Fut + Clone + Send + 'static,
|
||||||
Fut: Future<Output = ConduitResult<
|
Fut: Future<Output = Result<
|
||||||
<Req::Incoming as IncomingRequest>::OutgoingResponse
|
RumaResponse<<Req::Incoming as IncomingRequest>::OutgoingResponse>,
|
||||||
|
E,
|
||||||
>> + Send,
|
>> + Send,
|
||||||
|
E: IntoResponse,
|
||||||
$( $ty: FromRequest<axum::body::Body> + Send, )*
|
$( $ty: FromRequest<axum::body::Body> + Send, )*
|
||||||
{
|
{
|
||||||
const METADATA: Metadata = Req::Incoming::METADATA;
|
const METADATA: Metadata = Req::Incoming::METADATA;
|
||||||
|
|
Loading…
Reference in a new issue