lxy 0.1.1

A convenient async http and RPC framework in Rust
Documentation
use tower::Layer;

use super::App;

/// The layer binds [App] instance to be injected in request lifecycle.
#[derive(Clone)]
pub(crate) struct AppLayer(pub App);

impl<S> Layer<S> for AppLayer {
  type Service = AppService<S>;

  fn layer(&self, inner: S) -> Self::Service {
    AppService {
      app: self.0.clone(),
      inner,
    }
  }
}

/// Service that sets up [App] for each request.
/// Service implementations are delegated to concrete server providers.
#[derive(Clone)]
pub(crate) struct AppService<S> {
  pub(crate) app: App,
  pub(crate) inner: S,
}