All Downloads are FREE. Search and download functionalities are using the official Maven repository.

rust-server.server-service-header.mustache Maven / Gradle / Ivy

There is a newer version: 7.7.0
Show newest version
fn method_not_allowed() -> Result, crate::ServiceError> {
    Ok(
        Response::builder().status(StatusCode::METHOD_NOT_ALLOWED)
            .body(Body::empty())
            .expect("Unable to create Method Not Allowed response")
    )
}

pub struct Service where
    T: Api + Clone + Send + 'static,
    C: Has {{#hasAuthMethods}}+ Has>{{/hasAuthMethods}} + Send + Sync + 'static
{
    api_impl: T,
    marker: PhantomData,
}

impl Service where
    T: Api + Clone + Send + 'static,
    C: Has {{#hasAuthMethods}}+ Has>{{/hasAuthMethods}} + Send + Sync + 'static
{
    pub fn new(api_impl: T) -> Self {
        Service {
            api_impl,
            marker: PhantomData
        }
    }
}

impl Clone for Service where
    T: Api + Clone + Send + 'static,
    C: Has {{#hasAuthMethods}}+ Has>{{/hasAuthMethods}} + Send + Sync + 'static
{
    fn clone(&self) -> Self {
        Service {
            api_impl: self.api_impl.clone(),
            marker: self.marker,
        }
    }
}

impl hyper::service::Service<(Request, C)> for Service where
    T: Api + Clone + Send + Sync + 'static,
    C: Has {{#hasAuthMethods}}+ Has>{{/hasAuthMethods}} + Send + Sync + 'static
{
    type Response = Response;
    type Error = crate::ServiceError;
    type Future = ServiceFuture;

    fn poll_ready(&mut self, cx: &mut Context) -> Poll> {
        self.api_impl.poll_ready(cx)
    }

    fn call(&mut self, req: (Request, C)) -> Self::Future { async fn run(mut api_impl: T, req: (Request, C)) -> Result, crate::ServiceError> where
        T: Api + Clone + Send + 'static,
        C: Has {{#hasAuthMethods}}+ Has>{{/hasAuthMethods}} + Send + Sync + 'static
    {
        let (request, context) = req;
        let (parts, body) = request.into_parts();
        let (method, uri, headers) = (parts.method, parts.uri, parts.headers);
        let path = paths::GLOBAL_REGEX_SET.matches(uri.path());

        {{!
          This match statement is duplicated below in `parse_operation_id()`.
          Please update both places if changing how this code is autogenerated.
        }}
        match method {




© 2015 - 2024 Weber Informatics LLC | Privacy Policy