1use std::fmt;
2
3use ntex_h2 as h2;
4
5use crate::{Ctx, Service, ServiceFactory, http::error::DispatchError};
6
7#[derive(Debug, Default)]
8pub struct DefaultControlService;
10
11impl<St, E: fmt::Debug> Service<St, h2::Control<E>> for DefaultControlService {
12 type Res = h2::ControlAck;
13 type Error = DispatchError;
14
15 async fn call(
16 &self,
17 msg: h2::Control<E>,
18 _: Ctx<'_, Self, St>,
19 ) -> Result<Self::Res, Self::Error> {
20 log::trace!("HTTP/2 Control message: {msg:?}");
21 Ok(msg.ack())
22 }
23}
24
25impl<St, E: fmt::Debug> ServiceFactory<St, h2::Control<E>> for DefaultControlService {
26 type Res = h2::ControlAck;
27 type Error = DispatchError;
28
29 type Service = DefaultControlService;
30 type InitError = DispatchError;
31
32 async fn create(&self, _: &St) -> Result<Self::Service, Self::InitError> {
33 Ok(DefaultControlService)
34 }
35}