Start to stub out sub-services

This commit is contained in:
Lucien Greathouse
2019-02-22 13:08:07 -08:00
parent 6ea1211bc5
commit 105d8aeb6b
4 changed files with 62 additions and 14 deletions

View File

@@ -7,6 +7,11 @@ use std::{
sync::{mpsc, Arc},
};
use futures::{future, Future};
use hyper::{
service::Service,
Body,
};
use serde_derive::{Serialize, Deserialize};
use rouille::{
self,
@@ -83,6 +88,17 @@ pub struct ApiServer {
server_version: &'static str,
}
impl Service for ApiServer {
type ReqBody = Body;
type ResBody = Body;
type Error = hyper::Error;
type Future = Box<Future<Item = hyper::Response<Self::ReqBody>, Error = Self::Error> + Send>;
fn call(&mut self, request: hyper::Request<Self::ReqBody>) -> Self::Future {
Box::new(future::ok(hyper::Response::new(Body::from("Hello, from API!"))))
}
}
impl ApiServer {
pub fn new(live_session: Arc<LiveSession>) -> ApiServer {
ApiServer {