use Api; use hyper; use hyper::{Error, Request, Response, StatusCode}; use server::url::form_urlencoded; use std::io; use swagger::auth::{AuthData, Authorization, Scopes}; pub struct NewService where T: hyper::server::NewService< Request = (Request, Option), Response = Response, Error = Error, >, { inner: T, } impl NewService where T: hyper::server::NewService< Request = (Request, Option), Response = Response, Error = Error, > + 'static, { pub fn new(inner: T) -> NewService { NewService { inner } } } impl hyper::server::NewService for NewService where T: hyper::server::NewService< Request = (Request, Option), Response = Response, Error = Error, > + 'static, { type Request = Request; type Response = Response; type Error = Error; type Instance = Service; fn new_service(&self) -> Result { self.inner.new_service().map(|s| Service::new(s)) } } /// Middleware to extract authentication data from request pub struct Service where T: hyper::server::Service< Request = (Request, Option), Response = Response, Error = Error, >, { inner: T, } impl Service where T: hyper::server::Service< Request = (Request, Option), Response = Response, Error = Error, >, { pub fn new(inner: T) -> Service { Service { inner } } } impl hyper::server::Service for Service where T: hyper::server::Service< Request = (Request, Option), Response = Response, Error = Error, >, { type Request = Request; type Response = Response; type Error = Error; type Future = T::Future; fn call(&self, req: Self::Request) -> Self::Future { return self.inner.call((req, None)); } }