blob: 48672a17a386d08002ef0ec32923b665419a0a65 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
use super::handler::HandlerService;
use crate::config::Config;
use hyper::service::Service;
use shared::nats_crate::Client;
use std::{
future::{ready, Ready},
sync::Arc,
task::{Context, Poll},
};
use ed25519_dalek::PublicKey;
pub struct MakeSvc {
pub settings: Arc<Config>,
pub nats: Arc<Client>,
pub public_key: Arc<PublicKey>
}
impl<T> Service<T> for MakeSvc {
type Response = HandlerService;
type Error = std::io::Error;
type Future = Ready<Result<Self::Response, Self::Error>>;
fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
Ok(()).into()
}
fn call(&mut self, _: T) -> Self::Future {
ready(Ok(HandlerService {
config: self.settings.clone(),
nats: self.nats.clone(),
public_key: self.public_key.clone()
}))
}
}
|