summaryrefslogtreecommitdiffstats
path: root/rust/fatcat-openapi/src/server/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'rust/fatcat-openapi/src/server/mod.rs')
-rw-r--r--rust/fatcat-openapi/src/server/mod.rs16182
1 files changed, 8508 insertions, 7674 deletions
diff --git a/rust/fatcat-openapi/src/server/mod.rs b/rust/fatcat-openapi/src/server/mod.rs
index 96ed29a..ac07c6e 100644
--- a/rust/fatcat-openapi/src/server/mod.rs
+++ b/rust/fatcat-openapi/src/server/mod.rs
@@ -1,19 +1,16 @@
-use futures::{future, stream, Future, Stream};
-use hyper;
+use futures::{future, future::BoxFuture, future::FutureExt, stream, stream::TryStreamExt, Stream};
use hyper::header::{HeaderName, HeaderValue, CONTENT_TYPE};
-use hyper::{Body, Error, HeaderMap, Request, Response, StatusCode};
+use hyper::{Body, HeaderMap, Request, Response, StatusCode};
use log::warn;
-use serde_json;
#[allow(unused_imports)]
use std::convert::{TryFrom, TryInto};
-use std::io;
+use std::error::Error;
+use std::future::Future;
use std::marker::PhantomData;
-#[allow(unused_imports)]
-use swagger;
+use std::task::{Context, Poll};
pub use swagger::auth::Authorization;
use swagger::auth::Scopes;
-use swagger::context::ContextualPayload;
-use swagger::{ApiError, Has, RequestParser, XSpanIdString};
+use swagger::{ApiError, BodyExt, Has, RequestParser, XSpanIdString};
use url::form_urlencoded;
use crate::header;
@@ -22,6 +19,8 @@ use crate::models;
pub use crate::context;
+type ServiceFuture = BoxFuture<'static, Result<Response<Body>, crate::ServiceError>>;
+
use crate::{
AcceptEditgroupResponse, Api, AuthCheckResponse, AuthOidcResponse, CreateAuthTokenResponse,
CreateContainerAutoBatchResponse, CreateContainerResponse, CreateCreatorAutoBatchResponse,
@@ -610,15 +609,19 @@ mod paths {
}
}
-pub struct MakeService<T, RC> {
+pub struct MakeService<T, C>
+where
+ T: Api<C> + Clone + Send + 'static,
+ C: Has<XSpanIdString> + Has<Option<Authorization>> + Send + Sync + 'static,
+{
api_impl: T,
- marker: PhantomData<RC>,
+ marker: PhantomData<C>,
}
-impl<T, RC> MakeService<T, RC>
+impl<T, C> MakeService<T, C>
where
- T: Api<RC> + Clone + Send + 'static,
- RC: Has<XSpanIdString> + Has<Option<Authorization>> + 'static,
+ T: Api<C> + Clone + Send + 'static,
+ C: Has<XSpanIdString> + Has<Option<Authorization>> + Send + Sync + 'static,
{
pub fn new(api_impl: T) -> Self {
MakeService {
@@ -628,43 +631,44 @@ where
}
}
-impl<'a, T, SC, RC> hyper::service::MakeService<&'a SC> for MakeService<T, RC>
+impl<T, C, Target> hyper::service::Service<Target> for MakeService<T, C>
where
- T: Api<RC> + Clone + Send + 'static,
- RC: Has<XSpanIdString> + Has<Option<Authorization>> + 'static + Send,
+ T: Api<C> + Clone + Send + 'static,
+ C: Has<XSpanIdString> + Has<Option<Authorization>> + Send + Sync + 'static,
{
- type ReqBody = ContextualPayload<Body, RC>;
- type ResBody = Body;
- type Error = Error;
- type Service = Service<T, RC>;
- type Future = future::FutureResult<Self::Service, Self::MakeError>;
- type MakeError = Error;
-
- fn make_service(&mut self, _ctx: &'a SC) -> Self::Future {
- future::FutureResult::from(Ok(Service::new(self.api_impl.clone())))
+ type Response = Service<T, C>;
+ type Error = crate::ServiceError;
+ type Future = future::Ready<Result<Self::Response, Self::Error>>;
+
+ fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
+ Poll::Ready(Ok(()))
}
-}
-type ServiceFuture = Box<dyn Future<Item = Response<Body>, Error = Error> + Send>;
+ fn call(&mut self, target: Target) -> Self::Future {
+ futures::future::ok(Service::new(self.api_impl.clone()))
+ }
+}
-fn method_not_allowed() -> ServiceFuture {
- Box::new(future::ok(
- Response::builder()
- .status(StatusCode::METHOD_NOT_ALLOWED)
- .body(Body::empty())
- .expect("Unable to create Method Not Allowed response"),
- ))
+fn method_not_allowed() -> Result<Response<Body>, crate::ServiceError> {
+ Ok(Response::builder()
+ .status(StatusCode::METHOD_NOT_ALLOWED)
+ .body(Body::empty())
+ .expect("Unable to create Method Not Allowed response"))
}
-pub struct Service<T, RC> {
+pub struct Service<T, C>
+where
+ T: Api<C> + Clone + Send + 'static,
+ C: Has<XSpanIdString> + Has<Option<Authorization>> + Send + Sync + 'static,
+{
api_impl: T,
- marker: PhantomData<RC>,
+ marker: PhantomData<C>,
}
-impl<T, RC> Service<T, RC>
+impl<T, C> Service<T, C>
where
- T: Api<RC> + Clone + Send + 'static,
- RC: Has<XSpanIdString> + Has<Option<Authorization>> + 'static,
+ T: Api<C> + Clone + Send + 'static,
+ C: Has<XSpanIdString> + Has<Option<Authorization>> + Send + Sync + 'static,
{
pub fn new(api_impl: T) -> Self {
Service {
@@ -674,345 +678,376 @@ where
}
}
-impl<T, C> hyper::service::Service for Service<T, C>
+impl<T, C> Clone for Service<T, C>
where
T: Api<C> + Clone + Send + 'static,
- C: Has<XSpanIdString> + Has<Option<Authorization>> + 'static + Send,
+ C: Has<XSpanIdString> + Has<Option<Authorization>> + Send + Sync + 'static,
+{
+ fn clone(&self) -> Self {
+ Service {
+ api_impl: self.api_impl.clone(),
+ marker: self.marker.clone(),
+ }
+ }
+}
+
+impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C>
+where
+ T: Api<C> + Clone + Send + Sync + 'static,
+ C: Has<XSpanIdString> + Has<Option<Authorization>> + Send + Sync + 'static,
{
- type ReqBody = ContextualPayload<Body, C>;
- type ResBody = Body;
- type Error = Error;
+ type Response = Response<Body>;
+ type Error = crate::ServiceError;
type Future = ServiceFuture;
- fn call(&mut self, req: Request<Self::ReqBody>) -> Self::Future {
- let api_impl = self.api_impl.clone();
- let (parts, body) = req.into_parts();
- let (method, uri, headers) = (parts.method, parts.uri, parts.headers);
- let path = paths::GLOBAL_REGEX_SET.matches(uri.path());
- let mut context = body.context;
- let body = body.inner;
+ fn poll_ready(&mut self, cx: &mut Context) -> Poll<Result<(), Self::Error>> {
+ self.api_impl.poll_ready(cx)
+ }
- match &method {
- // AcceptEditgroup - POST /editgroup/{editgroup_id}/accept
- &hyper::Method::POST if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_ACCEPT) => {
- {
- let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
- &Some(ref authorization) => authorization,
- &None => {
- return Box::new(future::ok(
- Response::builder()
+ fn call(&mut self, req: (Request<Body>, C)) -> Self::Future {
+ async fn run<T, C>(
+ mut api_impl: T,
+ req: (Request<Body>, C),
+ ) -> Result<Response<Body>, crate::ServiceError>
+ where
+ T: Api<C> + Clone + Send + 'static,
+ C: Has<XSpanIdString> + Has<Option<Authorization>> + 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());
+
+ match &method {
+ // AcceptEditgroup - POST /editgroup/{editgroup_id}/accept
+ &hyper::Method::POST if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_ACCEPT) => {
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>)
+ .get()
+ {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Ok(Response::builder()
.status(StatusCode::FORBIDDEN)
.body(Body::from("Unauthenticated"))
- .expect("Unable to create Authentication Forbidden response"),
- ))
- }
- };
- }
+ .expect("Unable to create Authentication Forbidden response"))
+ }
+ };
+ }
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_EDITGROUP_EDITGROUP_ID_ACCEPT
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID_ACCEPT in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID_ACCEPT.as_str())
);
- let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
Ok(param_editgroup_id) => param_editgroup_id,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- Box::new({
- {
- {
- Box::new(
- api_impl.accept_editgroup(
- param_editgroup_id,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ let result = api_impl
+ .accept_editgroup(param_editgroup_id, &context)
+ .await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
- match result {
- Ok(rsp) => match rsp {
- AcceptEditgroupResponse::MergedSuccessfully
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ match result {
+ Ok(rsp) => match rsp {
+ AcceptEditgroupResponse::MergedSuccessfully(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for ACCEPT_EDITGROUP_MERGED_SUCCESSFULLY"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- AcceptEditgroupResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ AcceptEditgroupResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for ACCEPT_EDITGROUP_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- AcceptEditgroupResponse::NotAuthorized
- {
- body,
- www_authenticate
- }
- => {
- let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ AcceptEditgroupResponse::NotAuthorized {
+ body,
+ www_authenticate,
+ } => {
+ if let Some(www_authenticate) = www_authenticate {
+ let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
Ok(val) => val,
Err(e) => {
- return future::ok(Response::builder()
+ return Ok(Response::builder()
.status(StatusCode::INTERNAL_SERVER_ERROR)
.body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
.expect("Unable to create Internal Server Error for invalid response header"))
}
};
- *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
- response.headers_mut().insert(
- HeaderName::from_static("www_authenticate"),
- www_authenticate
- );
- response.headers_mut().insert(
+ response.headers_mut().insert(
+ HeaderName::from_static("www_authenticate"),
+ www_authenticate,
+ );
+ }
+ *response.status_mut() = StatusCode::from_u16(401)
+ .expect("Unable to turn 401 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for ACCEPT_EDITGROUP_NOT_AUTHORIZED"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- AcceptEditgroupResponse::Forbidden
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(403).expect("Unable to turn 403 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ AcceptEditgroupResponse::Forbidden(body) => {
+ *response.status_mut() = StatusCode::from_u16(403)
+ .expect("Unable to turn 403 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for ACCEPT_EDITGROUP_FORBIDDEN"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- AcceptEditgroupResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ AcceptEditgroupResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for ACCEPT_EDITGROUP_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- AcceptEditgroupResponse::EditConflict
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(409).expect("Unable to turn 409 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ AcceptEditgroupResponse::EditConflict(body) => {
+ *response.status_mut() = StatusCode::from_u16(409)
+ .expect("Unable to turn 409 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for ACCEPT_EDITGROUP_EDIT_CONFLICT"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- AcceptEditgroupResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ AcceptEditgroupResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for ACCEPT_EDITGROUP_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // AuthCheck - GET /auth/check
- &hyper::Method::GET if path.matched(paths::ID_AUTH_CHECK) => {
- {
- let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
- &Some(ref authorization) => authorization,
- &None => {
- return Box::new(future::ok(
- Response::builder()
- .status(StatusCode::FORBIDDEN)
- .body(Body::from("Unauthenticated"))
- .expect("Unable to create Authentication Forbidden response"),
- ))
- }
- };
+ Ok(response)
}
- // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
- let query_params =
- form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
- .collect::<Vec<_>>();
- let param_role = query_params
- .iter()
- .filter(|e| e.0 == "role")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_role = param_role.and_then(|param_role| param_role.parse().ok());
-
- Box::new({
+ // AuthCheck - GET /auth/check
+ &hyper::Method::GET if path.matched(paths::ID_AUTH_CHECK) => {
{
+ let authorization = match (&context as &dyn Has<Option<Authorization>>)
+ .get()
{
- Box::new(
- api_impl.auth_check(
- param_role,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Ok(Response::builder()
+ .status(StatusCode::FORBIDDEN)
+ .body(Body::from("Unauthenticated"))
+ .expect("Unable to create Authentication Forbidden response"))
+ }
+ };
+ }
- match result {
- Ok(rsp) => match rsp {
- AuthCheckResponse::Success
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_role = query_params
+ .iter()
+ .filter(|e| e.0 == "role")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_role = match param_role {
+ Some(param_role) => {
+ let param_role = <String as std::str::FromStr>::from_str(&param_role);
+ match param_role {
+ Ok(param_role) => Some(param_role),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter role - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter role")),
+ }
+ }
+ None => None,
+ };
+
+ let result = api_impl.auth_check(param_role, &context).await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
+
+ match result {
+ Ok(rsp) => match rsp {
+ AuthCheckResponse::Success(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for AUTH_CHECK_SUCCESS"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- AuthCheckResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ AuthCheckResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for AUTH_CHECK_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- AuthCheckResponse::NotAuthorized
- {
- body,
- www_authenticate
- }
- => {
- let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ AuthCheckResponse::NotAuthorized {
+ body,
+ www_authenticate,
+ } => {
+ if let Some(www_authenticate) = www_authenticate {
+ let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
Ok(val) => val,
Err(e) => {
- return future::ok(Response::builder()
+ return Ok(Response::builder()
.status(StatusCode::INTERNAL_SERVER_ERROR)
.body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
.expect("Unable to create Internal Server Error for invalid response header"))
}
};
- *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
- response.headers_mut().insert(
- HeaderName::from_static("www_authenticate"),
- www_authenticate
- );
- response.headers_mut().insert(
+ response.headers_mut().insert(
+ HeaderName::from_static("www_authenticate"),
+ www_authenticate,
+ );
+ }
+ *response.status_mut() = StatusCode::from_u16(401)
+ .expect("Unable to turn 401 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for AUTH_CHECK_NOT_AUTHORIZED"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- AuthCheckResponse::Forbidden
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(403).expect("Unable to turn 403 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ AuthCheckResponse::Forbidden(body) => {
+ *response.status_mut() = StatusCode::from_u16(403)
+ .expect("Unable to turn 403 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for AUTH_CHECK_FORBIDDEN"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- AuthCheckResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ AuthCheckResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for AUTH_CHECK_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // AuthOidc - POST /auth/oidc
- &hyper::Method::POST if path.matched(paths::ID_AUTH_OIDC) => {
- {
- let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
- &Some(ref authorization) => authorization,
- &None => {
- return Box::new(future::ok(
- Response::builder()
+ Ok(response)
+ }
+
+ // AuthOidc - POST /auth/oidc
+ &hyper::Method::POST if path.matched(paths::ID_AUTH_OIDC) => {
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>)
+ .get()
+ {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Ok(Response::builder()
.status(StatusCode::FORBIDDEN)
.body(Body::from("Unauthenticated"))
- .expect("Unable to create Authentication Forbidden response"),
- ))
- }
- };
- }
+ .expect("Unable to create Authentication Forbidden response"))
+ }
+ };
+ }
- // Body parameters (note that non-required body parameters will ignore garbage
- // values, rather than causing a 400 response). Produce warning header and logs for
- // any unused fields.
- Box::new(body.concat2()
- .then(move |result| -> Self::Future {
- match result {
+ // Body parameters (note that non-required body parameters will ignore garbage
+ // values, rather than causing a 400 response). Produce warning header and logs for
+ // any unused fields.
+ let result = body.to_raw().await;
+ match result {
Ok(body) => {
let mut unused_elements = Vec::new();
let param_auth_oidc: Option<models::AuthOidc> = if !body.is_empty() {
@@ -1022,29 +1057,28 @@ where
unused_elements.push(path.to_string());
}) {
Ok(param_auth_oidc) => param_auth_oidc,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse body parameter AuthOidc - doesn't match schema: {}", e)))
- .expect("Unable to create Bad Request response for invalid body parameter AuthOidc due to schema"))),
+ .expect("Unable to create Bad Request response for invalid body parameter AuthOidc due to schema")),
}
} else {
None
};
let param_auth_oidc = match param_auth_oidc {
Some(param_auth_oidc) => param_auth_oidc,
- None => return Box::new(future::ok(Response::builder()
+ None => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from("Missing required body parameter AuthOidc"))
- .expect("Unable to create Bad Request response for missing body parameter AuthOidc"))),
+ .expect("Unable to create Bad Request response for missing body parameter AuthOidc")),
};
- Box::new(
- api_impl.auth_oidc(
+ let result = api_impl.auth_oidc(
param_auth_oidc,
&context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
+ ).await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
HeaderName::from_static("x-span-id"),
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
.expect("Unable to create X-Span-ID header value"));
@@ -1097,21 +1131,23 @@ where
www_authenticate
}
=> {
+ if let Some(www_authenticate) = www_authenticate {
let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
Ok(val) => val,
Err(e) => {
- return future::ok(Response::builder()
+ return Ok(Response::builder()
.status(StatusCode::INTERNAL_SERVER_ERROR)
.body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
.expect("Unable to create Internal Server Error for invalid response header"))
}
};
- *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
response.headers_mut().insert(
HeaderName::from_static("www_authenticate"),
www_authenticate
);
+ }
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
@@ -1161,221 +1197,229 @@ where
},
}
- future::ok(response)
- }
- ))
+ Ok(response)
},
- Err(e) => Box::new(future::ok(Response::builder()
+ Err(e) => Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't read body parameter AuthOidc: {}", e)))
- .expect("Unable to create Bad Request response due to unable to read body parameter AuthOidc"))),
+ .expect("Unable to create Bad Request response due to unable to read body parameter AuthOidc")),
}
- })
- ) as Self::Future
- }
+ }
- // CreateAuthToken - POST /auth/token/{editor_id}
- &hyper::Method::POST if path.matched(paths::ID_AUTH_TOKEN_EDITOR_ID) => {
- {
- let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
- &Some(ref authorization) => authorization,
- &None => {
- return Box::new(future::ok(
- Response::builder()
+ // CreateAuthToken - POST /auth/token/{editor_id}
+ &hyper::Method::POST if path.matched(paths::ID_AUTH_TOKEN_EDITOR_ID) => {
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>)
+ .get()
+ {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Ok(Response::builder()
.status(StatusCode::FORBIDDEN)
.body(Body::from("Unauthenticated"))
- .expect("Unable to create Authentication Forbidden response"),
- ))
- }
- };
- }
+ .expect("Unable to create Authentication Forbidden response"))
+ }
+ };
+ }
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_AUTH_TOKEN_EDITOR_ID
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE AUTH_TOKEN_EDITOR_ID in set but failed match against \"{}\"", path, paths::REGEX_AUTH_TOKEN_EDITOR_ID.as_str())
);
- let param_editor_id = match percent_encoding::percent_decode(path_params["editor_id"].as_bytes()).decode_utf8() {
+ let param_editor_id = match percent_encoding::percent_decode(path_params["editor_id"].as_bytes()).decode_utf8() {
Ok(param_editor_id) => match param_editor_id.parse::<String>() {
Ok(param_editor_id) => param_editor_id,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter editor_id: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editor_id"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
- let query_params =
- form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
- .collect::<Vec<_>>();
- let param_duration_seconds = query_params
- .iter()
- .filter(|e| e.0 == "duration_seconds")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_duration_seconds = param_duration_seconds
- .and_then(|param_duration_seconds| param_duration_seconds.parse().ok());
-
- Box::new({
- {
- {
- Box::new(
- api_impl.create_auth_token(
- param_editor_id,
- param_duration_seconds,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_duration_seconds = query_params
+ .iter()
+ .filter(|e| e.0 == "duration_seconds")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_duration_seconds = match param_duration_seconds {
+ Some(param_duration_seconds) => {
+ let param_duration_seconds =
+ <i32 as std::str::FromStr>::from_str(&param_duration_seconds);
+ match param_duration_seconds {
+ Ok(param_duration_seconds) => Some(param_duration_seconds),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter duration_seconds - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter duration_seconds")),
+ }
+ }
+ None => None,
+ };
- match result {
- Ok(rsp) => match rsp {
- CreateAuthTokenResponse::Success
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ let result = api_impl
+ .create_auth_token(param_editor_id, param_duration_seconds, &context)
+ .await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
+
+ match result {
+ Ok(rsp) => match rsp {
+ CreateAuthTokenResponse::Success(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for CREATE_AUTH_TOKEN_SUCCESS"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- CreateAuthTokenResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ CreateAuthTokenResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for CREATE_AUTH_TOKEN_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- CreateAuthTokenResponse::NotAuthorized
- {
- body,
- www_authenticate
- }
- => {
- let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ CreateAuthTokenResponse::NotAuthorized {
+ body,
+ www_authenticate,
+ } => {
+ if let Some(www_authenticate) = www_authenticate {
+ let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
Ok(val) => val,
Err(e) => {
- return future::ok(Response::builder()
+ return Ok(Response::builder()
.status(StatusCode::INTERNAL_SERVER_ERROR)
.body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
.expect("Unable to create Internal Server Error for invalid response header"))
}
};
- *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
- response.headers_mut().insert(
- HeaderName::from_static("www_authenticate"),
- www_authenticate
- );
- response.headers_mut().insert(
+ response.headers_mut().insert(
+ HeaderName::from_static("www_authenticate"),
+ www_authenticate,
+ );
+ }
+ *response.status_mut() = StatusCode::from_u16(401)
+ .expect("Unable to turn 401 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for CREATE_AUTH_TOKEN_NOT_AUTHORIZED"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- CreateAuthTokenResponse::Forbidden
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(403).expect("Unable to turn 403 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ CreateAuthTokenResponse::Forbidden(body) => {
+ *response.status_mut() = StatusCode::from_u16(403)
+ .expect("Unable to turn 403 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for CREATE_AUTH_TOKEN_FORBIDDEN"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- CreateAuthTokenResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ CreateAuthTokenResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for CREATE_AUTH_TOKEN_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // CreateContainer - POST /editgroup/{editgroup_id}/container
- &hyper::Method::POST if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_CONTAINER) => {
+ Ok(response)
+ }
+
+ // CreateContainer - POST /editgroup/{editgroup_id}/container
+ &hyper::Method::POST
+ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_CONTAINER) =>
{
- let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
- &Some(ref authorization) => authorization,
- &None => {
- return Box::new(future::ok(
- Response::builder()
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>)
+ .get()
+ {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Ok(Response::builder()
.status(StatusCode::FORBIDDEN)
.body(Body::from("Unauthenticated"))
- .expect("Unable to create Authentication Forbidden response"),
- ))
- }
- };
- }
+ .expect("Unable to create Authentication Forbidden response"))
+ }
+ };
+ }
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_EDITGROUP_EDITGROUP_ID_CONTAINER
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID_CONTAINER in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID_CONTAINER.as_str())
);
- let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
Ok(param_editgroup_id) => param_editgroup_id,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- // Body parameters (note that non-required body parameters will ignore garbage
- // values, rather than causing a 400 response). Produce warning header and logs for
- // any unused fields.
- Box::new(body.concat2()
- .then(move |result| -> Self::Future {
- match result {
+ // Body parameters (note that non-required body parameters will ignore garbage
+ // values, rather than causing a 400 response). Produce warning header and logs for
+ // any unused fields.
+ let result = body.to_raw().await;
+ match result {
Ok(body) => {
let mut unused_elements = Vec::new();
let param_container_entity: Option<models::ContainerEntity> = if !body.is_empty() {
@@ -1385,30 +1429,29 @@ where
unused_elements.push(path.to_string());
}) {
Ok(param_container_entity) => param_container_entity,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse body parameter ContainerEntity - doesn't match schema: {}", e)))
- .expect("Unable to create Bad Request response for invalid body parameter ContainerEntity due to schema"))),
+ .expect("Unable to create Bad Request response for invalid body parameter ContainerEntity due to schema")),
}
} else {
None
};
let param_container_entity = match param_container_entity {
Some(param_container_entity) => param_container_entity,
- None => return Box::new(future::ok(Response::builder()
+ None => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from("Missing required body parameter ContainerEntity"))
- .expect("Unable to create Bad Request response for missing body parameter ContainerEntity"))),
+ .expect("Unable to create Bad Request response for missing body parameter ContainerEntity")),
};
- Box::new(
- api_impl.create_container(
+ let result = api_impl.create_container(
param_editgroup_id,
param_container_entity,
&context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
+ ).await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
HeaderName::from_static("x-span-id"),
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
.expect("Unable to create X-Span-ID header value"));
@@ -1450,21 +1493,23 @@ where
www_authenticate
}
=> {
+ if let Some(www_authenticate) = www_authenticate {
let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
Ok(val) => val,
Err(e) => {
- return future::ok(Response::builder()
+ return Ok(Response::builder()
.status(StatusCode::INTERNAL_SERVER_ERROR)
.body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
.expect("Unable to create Internal Server Error for invalid response header"))
}
};
- *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
response.headers_mut().insert(
HeaderName::from_static("www_authenticate"),
www_authenticate
);
+ }
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
@@ -1514,41 +1559,36 @@ where
},
}
- future::ok(response)
- }
- ))
+ Ok(response)
},
- Err(e) => Box::new(future::ok(Response::builder()
+ Err(e) => Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't read body parameter ContainerEntity: {}", e)))
- .expect("Unable to create Bad Request response due to unable to read body parameter ContainerEntity"))),
+ .expect("Unable to create Bad Request response due to unable to read body parameter ContainerEntity")),
}
- })
- ) as Self::Future
- }
+ }
- // CreateContainerAutoBatch - POST /editgroup/auto/container/batch
- &hyper::Method::POST if path.matched(paths::ID_EDITGROUP_AUTO_CONTAINER_BATCH) => {
- {
- let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
- &Some(ref authorization) => authorization,
- &None => {
- return Box::new(future::ok(
- Response::builder()
+ // CreateContainerAutoBatch - POST /editgroup/auto/container/batch
+ &hyper::Method::POST if path.matched(paths::ID_EDITGROUP_AUTO_CONTAINER_BATCH) => {
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>)
+ .get()
+ {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Ok(Response::builder()
.status(StatusCode::FORBIDDEN)
.body(Body::from("Unauthenticated"))
- .expect("Unable to create Authentication Forbidden response"),
- ))
- }
- };
- }
+ .expect("Unable to create Authentication Forbidden response"))
+ }
+ };
+ }
- // Body parameters (note that non-required body parameters will ignore garbage
- // values, rather than causing a 400 response). Produce warning header and logs for
- // any unused fields.
- Box::new(body.concat2()
- .then(move |result| -> Self::Future {
- match result {
+ // Body parameters (note that non-required body parameters will ignore garbage
+ // values, rather than causing a 400 response). Produce warning header and logs for
+ // any unused fields.
+ let result = body.to_raw().await;
+ match result {
Ok(body) => {
let mut unused_elements = Vec::new();
let param_container_auto_batch: Option<models::ContainerAutoBatch> = if !body.is_empty() {
@@ -1558,29 +1598,28 @@ where
unused_elements.push(path.to_string());
}) {
Ok(param_container_auto_batch) => param_container_auto_batch,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse body parameter ContainerAutoBatch - doesn't match schema: {}", e)))
- .expect("Unable to create Bad Request response for invalid body parameter ContainerAutoBatch due to schema"))),
+ .expect("Unable to create Bad Request response for invalid body parameter ContainerAutoBatch due to schema")),
}
} else {
None
};
let param_container_auto_batch = match param_container_auto_batch {
Some(param_container_auto_batch) => param_container_auto_batch,
- None => return Box::new(future::ok(Response::builder()
+ None => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from("Missing required body parameter ContainerAutoBatch"))
- .expect("Unable to create Bad Request response for missing body parameter ContainerAutoBatch"))),
+ .expect("Unable to create Bad Request response for missing body parameter ContainerAutoBatch")),
};
- Box::new(
- api_impl.create_container_auto_batch(
+ let result = api_impl.create_container_auto_batch(
param_container_auto_batch,
&context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
+ ).await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
HeaderName::from_static("x-span-id"),
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
.expect("Unable to create X-Span-ID header value"));
@@ -1622,21 +1661,23 @@ where
www_authenticate
}
=> {
+ if let Some(www_authenticate) = www_authenticate {
let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
Ok(val) => val,
Err(e) => {
- return future::ok(Response::builder()
+ return Ok(Response::builder()
.status(StatusCode::INTERNAL_SERVER_ERROR)
.body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
.expect("Unable to create Internal Server Error for invalid response header"))
}
};
- *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
response.headers_mut().insert(
HeaderName::from_static("www_authenticate"),
www_authenticate
);
+ }
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
@@ -1686,64 +1727,59 @@ where
},
}
- future::ok(response)
- }
- ))
+ Ok(response)
},
- Err(e) => Box::new(future::ok(Response::builder()
+ Err(e) => Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't read body parameter ContainerAutoBatch: {}", e)))
- .expect("Unable to create Bad Request response due to unable to read body parameter ContainerAutoBatch"))),
+ .expect("Unable to create Bad Request response due to unable to read body parameter ContainerAutoBatch")),
}
- })
- ) as Self::Future
- }
+ }
- // CreateCreator - POST /editgroup/{editgroup_id}/creator
- &hyper::Method::POST if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_CREATOR) => {
- {
- let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
- &Some(ref authorization) => authorization,
- &None => {
- return Box::new(future::ok(
- Response::builder()
+ // CreateCreator - POST /editgroup/{editgroup_id}/creator
+ &hyper::Method::POST if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_CREATOR) => {
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>)
+ .get()
+ {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Ok(Response::builder()
.status(StatusCode::FORBIDDEN)
.body(Body::from("Unauthenticated"))
- .expect("Unable to create Authentication Forbidden response"),
- ))
- }
- };
- }
+ .expect("Unable to create Authentication Forbidden response"))
+ }
+ };
+ }
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_EDITGROUP_EDITGROUP_ID_CREATOR
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID_CREATOR in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID_CREATOR.as_str())
);
- let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
Ok(param_editgroup_id) => param_editgroup_id,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- // Body parameters (note that non-required body parameters will ignore garbage
- // values, rather than causing a 400 response). Produce warning header and logs for
- // any unused fields.
- Box::new(body.concat2()
- .then(move |result| -> Self::Future {
- match result {
+ // Body parameters (note that non-required body parameters will ignore garbage
+ // values, rather than causing a 400 response). Produce warning header and logs for
+ // any unused fields.
+ let result = body.to_raw().await;
+ match result {
Ok(body) => {
let mut unused_elements = Vec::new();
let param_creator_entity: Option<models::CreatorEntity> = if !body.is_empty() {
@@ -1753,30 +1789,29 @@ where
unused_elements.push(path.to_string());
}) {
Ok(param_creator_entity) => param_creator_entity,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse body parameter CreatorEntity - doesn't match schema: {}", e)))
- .expect("Unable to create Bad Request response for invalid body parameter CreatorEntity due to schema"))),
+ .expect("Unable to create Bad Request response for invalid body parameter CreatorEntity due to schema")),
}
} else {
None
};
let param_creator_entity = match param_creator_entity {
Some(param_creator_entity) => param_creator_entity,
- None => return Box::new(future::ok(Response::builder()
+ None => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from("Missing required body parameter CreatorEntity"))
- .expect("Unable to create Bad Request response for missing body parameter CreatorEntity"))),
+ .expect("Unable to create Bad Request response for missing body parameter CreatorEntity")),
};
- Box::new(
- api_impl.create_creator(
+ let result = api_impl.create_creator(
param_editgroup_id,
param_creator_entity,
&context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
+ ).await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
HeaderName::from_static("x-span-id"),
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
.expect("Unable to create X-Span-ID header value"));
@@ -1818,21 +1853,23 @@ where
www_authenticate
}
=> {
+ if let Some(www_authenticate) = www_authenticate {
let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
Ok(val) => val,
Err(e) => {
- return future::ok(Response::builder()
+ return Ok(Response::builder()
.status(StatusCode::INTERNAL_SERVER_ERROR)
.body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
.expect("Unable to create Internal Server Error for invalid response header"))
}
};
- *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
response.headers_mut().insert(
HeaderName::from_static("www_authenticate"),
www_authenticate
);
+ }
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
@@ -1882,41 +1919,36 @@ where
},
}
- future::ok(response)
- }
- ))
+ Ok(response)
},
- Err(e) => Box::new(future::ok(Response::builder()
+ Err(e) => Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't read body parameter CreatorEntity: {}", e)))
- .expect("Unable to create Bad Request response due to unable to read body parameter CreatorEntity"))),
+ .expect("Unable to create Bad Request response due to unable to read body parameter CreatorEntity")),
}
- })
- ) as Self::Future
- }
+ }
- // CreateCreatorAutoBatch - POST /editgroup/auto/creator/batch
- &hyper::Method::POST if path.matched(paths::ID_EDITGROUP_AUTO_CREATOR_BATCH) => {
- {
- let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
- &Some(ref authorization) => authorization,
- &None => {
- return Box::new(future::ok(
- Response::builder()
+ // CreateCreatorAutoBatch - POST /editgroup/auto/creator/batch
+ &hyper::Method::POST if path.matched(paths::ID_EDITGROUP_AUTO_CREATOR_BATCH) => {
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>)
+ .get()
+ {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Ok(Response::builder()
.status(StatusCode::FORBIDDEN)
.body(Body::from("Unauthenticated"))
- .expect("Unable to create Authentication Forbidden response"),
- ))
- }
- };
- }
+ .expect("Unable to create Authentication Forbidden response"))
+ }
+ };
+ }
- // Body parameters (note that non-required body parameters will ignore garbage
- // values, rather than causing a 400 response). Produce warning header and logs for
- // any unused fields.
- Box::new(body.concat2()
- .then(move |result| -> Self::Future {
- match result {
+ // Body parameters (note that non-required body parameters will ignore garbage
+ // values, rather than causing a 400 response). Produce warning header and logs for
+ // any unused fields.
+ let result = body.to_raw().await;
+ match result {
Ok(body) => {
let mut unused_elements = Vec::new();
let param_creator_auto_batch: Option<models::CreatorAutoBatch> = if !body.is_empty() {
@@ -1926,29 +1958,28 @@ where
unused_elements.push(path.to_string());
}) {
Ok(param_creator_auto_batch) => param_creator_auto_batch,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse body parameter CreatorAutoBatch - doesn't match schema: {}", e)))
- .expect("Unable to create Bad Request response for invalid body parameter CreatorAutoBatch due to schema"))),
+ .expect("Unable to create Bad Request response for invalid body parameter CreatorAutoBatch due to schema")),
}
} else {
None
};
let param_creator_auto_batch = match param_creator_auto_batch {
Some(param_creator_auto_batch) => param_creator_auto_batch,
- None => return Box::new(future::ok(Response::builder()
+ None => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from("Missing required body parameter CreatorAutoBatch"))
- .expect("Unable to create Bad Request response for missing body parameter CreatorAutoBatch"))),
+ .expect("Unable to create Bad Request response for missing body parameter CreatorAutoBatch")),
};
- Box::new(
- api_impl.create_creator_auto_batch(
+ let result = api_impl.create_creator_auto_batch(
param_creator_auto_batch,
&context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
+ ).await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
HeaderName::from_static("x-span-id"),
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
.expect("Unable to create X-Span-ID header value"));
@@ -1990,21 +2021,23 @@ where
www_authenticate
}
=> {
+ if let Some(www_authenticate) = www_authenticate {
let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
Ok(val) => val,
Err(e) => {
- return future::ok(Response::builder()
+ return Ok(Response::builder()
.status(StatusCode::INTERNAL_SERVER_ERROR)
.body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
.expect("Unable to create Internal Server Error for invalid response header"))
}
};
- *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
response.headers_mut().insert(
HeaderName::from_static("www_authenticate"),
www_authenticate
);
+ }
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
@@ -2054,41 +2087,36 @@ where
},
}
- future::ok(response)
- }
- ))
+ Ok(response)
},
- Err(e) => Box::new(future::ok(Response::builder()
+ Err(e) => Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't read body parameter CreatorAutoBatch: {}", e)))
- .expect("Unable to create Bad Request response due to unable to read body parameter CreatorAutoBatch"))),
+ .expect("Unable to create Bad Request response due to unable to read body parameter CreatorAutoBatch")),
}
- })
- ) as Self::Future
- }
+ }
- // CreateEditgroup - POST /editgroup
- &hyper::Method::POST if path.matched(paths::ID_EDITGROUP) => {
- {
- let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
- &Some(ref authorization) => authorization,
- &None => {
- return Box::new(future::ok(
- Response::builder()
+ // CreateEditgroup - POST /editgroup
+ &hyper::Method::POST if path.matched(paths::ID_EDITGROUP) => {
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>)
+ .get()
+ {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Ok(Response::builder()
.status(StatusCode::FORBIDDEN)
.body(Body::from("Unauthenticated"))
- .expect("Unable to create Authentication Forbidden response"),
- ))
- }
- };
- }
+ .expect("Unable to create Authentication Forbidden response"))
+ }
+ };
+ }
- // Body parameters (note that non-required body parameters will ignore garbage
- // values, rather than causing a 400 response). Produce warning header and logs for
- // any unused fields.
- Box::new(body.concat2()
- .then(move |result| -> Self::Future {
- match result {
+ // Body parameters (note that non-required body parameters will ignore garbage
+ // values, rather than causing a 400 response). Produce warning header and logs for
+ // any unused fields.
+ let result = body.to_raw().await;
+ match result {
Ok(body) => {
let mut unused_elements = Vec::new();
let param_editgroup: Option<models::Editgroup> = if !body.is_empty() {
@@ -2098,29 +2126,28 @@ where
unused_elements.push(path.to_string());
}) {
Ok(param_editgroup) => param_editgroup,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse body parameter Editgroup - doesn't match schema: {}", e)))
- .expect("Unable to create Bad Request response for invalid body parameter Editgroup due to schema"))),
+ .expect("Unable to create Bad Request response for invalid body parameter Editgroup due to schema")),
}
} else {
None
};
let param_editgroup = match param_editgroup {
Some(param_editgroup) => param_editgroup,
- None => return Box::new(future::ok(Response::builder()
+ None => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from("Missing required body parameter Editgroup"))
- .expect("Unable to create Bad Request response for missing body parameter Editgroup"))),
+ .expect("Unable to create Bad Request response for missing body parameter Editgroup")),
};
- Box::new(
- api_impl.create_editgroup(
+ let result = api_impl.create_editgroup(
param_editgroup,
&context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
+ ).await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
HeaderName::from_static("x-span-id"),
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
.expect("Unable to create X-Span-ID header value"));
@@ -2162,21 +2189,23 @@ where
www_authenticate
}
=> {
+ if let Some(www_authenticate) = www_authenticate {
let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
Ok(val) => val,
Err(e) => {
- return future::ok(Response::builder()
+ return Ok(Response::builder()
.status(StatusCode::INTERNAL_SERVER_ERROR)
.body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
.expect("Unable to create Internal Server Error for invalid response header"))
}
};
- *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
response.headers_mut().insert(
HeaderName::from_static("www_authenticate"),
www_authenticate
);
+ }
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
@@ -2226,64 +2255,61 @@ where
},
}
- future::ok(response)
- }
- ))
+ Ok(response)
},
- Err(e) => Box::new(future::ok(Response::builder()
+ Err(e) => Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't read body parameter Editgroup: {}", e)))
- .expect("Unable to create Bad Request response due to unable to read body parameter Editgroup"))),
+ .expect("Unable to create Bad Request response due to unable to read body parameter Editgroup")),
}
- })
- ) as Self::Future
- }
+ }
- // CreateEditgroupAnnotation - POST /editgroup/{editgroup_id}/annotation
- &hyper::Method::POST if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_ANNOTATION) => {
+ // CreateEditgroupAnnotation - POST /editgroup/{editgroup_id}/annotation
+ &hyper::Method::POST
+ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_ANNOTATION) =>
{
- let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
- &Some(ref authorization) => authorization,
- &None => {
- return Box::new(future::ok(
- Response::builder()
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>)
+ .get()
+ {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Ok(Response::builder()
.status(StatusCode::FORBIDDEN)
.body(Body::from("Unauthenticated"))
- .expect("Unable to create Authentication Forbidden response"),
- ))
- }
- };
- }
+ .expect("Unable to create Authentication Forbidden response"))
+ }
+ };
+ }
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_EDITGROUP_EDITGROUP_ID_ANNOTATION
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID_ANNOTATION in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID_ANNOTATION.as_str())
);
- let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
Ok(param_editgroup_id) => param_editgroup_id,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- // Body parameters (note that non-required body parameters will ignore garbage
- // values, rather than causing a 400 response). Produce warning header and logs for
- // any unused fields.
- Box::new(body.concat2()
- .then(move |result| -> Self::Future {
- match result {
+ // Body parameters (note that non-required body parameters will ignore garbage
+ // values, rather than causing a 400 response). Produce warning header and logs for
+ // any unused fields.
+ let result = body.to_raw().await;
+ match result {
Ok(body) => {
let mut unused_elements = Vec::new();
let param_editgroup_annotation: Option<models::EditgroupAnnotation> = if !body.is_empty() {
@@ -2293,30 +2319,29 @@ where
unused_elements.push(path.to_string());
}) {
Ok(param_editgroup_annotation) => param_editgroup_annotation,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse body parameter EditgroupAnnotation - doesn't match schema: {}", e)))
- .expect("Unable to create Bad Request response for invalid body parameter EditgroupAnnotation due to schema"))),
+ .expect("Unable to create Bad Request response for invalid body parameter EditgroupAnnotation due to schema")),
}
} else {
None
};
let param_editgroup_annotation = match param_editgroup_annotation {
Some(param_editgroup_annotation) => param_editgroup_annotation,
- None => return Box::new(future::ok(Response::builder()
+ None => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from("Missing required body parameter EditgroupAnnotation"))
- .expect("Unable to create Bad Request response for missing body parameter EditgroupAnnotation"))),
+ .expect("Unable to create Bad Request response for missing body parameter EditgroupAnnotation")),
};
- Box::new(
- api_impl.create_editgroup_annotation(
+ let result = api_impl.create_editgroup_annotation(
param_editgroup_id,
param_editgroup_annotation,
&context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
+ ).await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
HeaderName::from_static("x-span-id"),
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
.expect("Unable to create X-Span-ID header value"));
@@ -2358,21 +2383,23 @@ where
www_authenticate
}
=> {
+ if let Some(www_authenticate) = www_authenticate {
let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
Ok(val) => val,
Err(e) => {
- return future::ok(Response::builder()
+ return Ok(Response::builder()
.status(StatusCode::INTERNAL_SERVER_ERROR)
.body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
.expect("Unable to create Internal Server Error for invalid response header"))
}
};
- *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
response.headers_mut().insert(
HeaderName::from_static("www_authenticate"),
www_authenticate
);
+ }
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
@@ -2422,64 +2449,59 @@ where
},
}
- future::ok(response)
- }
- ))
+ Ok(response)
},
- Err(e) => Box::new(future::ok(Response::builder()
+ Err(e) => Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't read body parameter EditgroupAnnotation: {}", e)))
- .expect("Unable to create Bad Request response due to unable to read body parameter EditgroupAnnotation"))),
+ .expect("Unable to create Bad Request response due to unable to read body parameter EditgroupAnnotation")),
}
- })
- ) as Self::Future
- }
+ }
- // CreateFile - POST /editgroup/{editgroup_id}/file
- &hyper::Method::POST if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_FILE) => {
- {
- let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
- &Some(ref authorization) => authorization,
- &None => {
- return Box::new(future::ok(
- Response::builder()
+ // CreateFile - POST /editgroup/{editgroup_id}/file
+ &hyper::Method::POST if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_FILE) => {
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>)
+ .get()
+ {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Ok(Response::builder()
.status(StatusCode::FORBIDDEN)
.body(Body::from("Unauthenticated"))
- .expect("Unable to create Authentication Forbidden response"),
- ))
- }
- };
- }
+ .expect("Unable to create Authentication Forbidden response"))
+ }
+ };
+ }
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_EDITGROUP_EDITGROUP_ID_FILE
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID_FILE in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID_FILE.as_str())
);
- let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
Ok(param_editgroup_id) => param_editgroup_id,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- // Body parameters (note that non-required body parameters will ignore garbage
- // values, rather than causing a 400 response). Produce warning header and logs for
- // any unused fields.
- Box::new(body.concat2()
- .then(move |result| -> Self::Future {
- match result {
+ // Body parameters (note that non-required body parameters will ignore garbage
+ // values, rather than causing a 400 response). Produce warning header and logs for
+ // any unused fields.
+ let result = body.to_raw().await;
+ match result {
Ok(body) => {
let mut unused_elements = Vec::new();
let param_file_entity: Option<models::FileEntity> = if !body.is_empty() {
@@ -2489,30 +2511,29 @@ where
unused_elements.push(path.to_string());
}) {
Ok(param_file_entity) => param_file_entity,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse body parameter FileEntity - doesn't match schema: {}", e)))
- .expect("Unable to create Bad Request response for invalid body parameter FileEntity due to schema"))),
+ .expect("Unable to create Bad Request response for invalid body parameter FileEntity due to schema")),
}
} else {
None
};
let param_file_entity = match param_file_entity {
Some(param_file_entity) => param_file_entity,
- None => return Box::new(future::ok(Response::builder()
+ None => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from("Missing required body parameter FileEntity"))
- .expect("Unable to create Bad Request response for missing body parameter FileEntity"))),
+ .expect("Unable to create Bad Request response for missing body parameter FileEntity")),
};
- Box::new(
- api_impl.create_file(
+ let result = api_impl.create_file(
param_editgroup_id,
param_file_entity,
&context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
+ ).await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
HeaderName::from_static("x-span-id"),
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
.expect("Unable to create X-Span-ID header value"));
@@ -2554,21 +2575,23 @@ where
www_authenticate
}
=> {
+ if let Some(www_authenticate) = www_authenticate {
let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
Ok(val) => val,
Err(e) => {
- return future::ok(Response::builder()
+ return Ok(Response::builder()
.status(StatusCode::INTERNAL_SERVER_ERROR)
.body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
.expect("Unable to create Internal Server Error for invalid response header"))
}
};
- *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
response.headers_mut().insert(
HeaderName::from_static("www_authenticate"),
www_authenticate
);
+ }
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
@@ -2618,41 +2641,36 @@ where
},
}
- future::ok(response)
- }
- ))
+ Ok(response)
},
- Err(e) => Box::new(future::ok(Response::builder()
+ Err(e) => Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't read body parameter FileEntity: {}", e)))
- .expect("Unable to create Bad Request response due to unable to read body parameter FileEntity"))),
+ .expect("Unable to create Bad Request response due to unable to read body parameter FileEntity")),
}
- })
- ) as Self::Future
- }
+ }
- // CreateFileAutoBatch - POST /editgroup/auto/file/batch
- &hyper::Method::POST if path.matched(paths::ID_EDITGROUP_AUTO_FILE_BATCH) => {
- {
- let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
- &Some(ref authorization) => authorization,
- &None => {
- return Box::new(future::ok(
- Response::builder()
+ // CreateFileAutoBatch - POST /editgroup/auto/file/batch
+ &hyper::Method::POST if path.matched(paths::ID_EDITGROUP_AUTO_FILE_BATCH) => {
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>)
+ .get()
+ {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Ok(Response::builder()
.status(StatusCode::FORBIDDEN)
.body(Body::from("Unauthenticated"))
- .expect("Unable to create Authentication Forbidden response"),
- ))
- }
- };
- }
+ .expect("Unable to create Authentication Forbidden response"))
+ }
+ };
+ }
- // Body parameters (note that non-required body parameters will ignore garbage
- // values, rather than causing a 400 response). Produce warning header and logs for
- // any unused fields.
- Box::new(body.concat2()
- .then(move |result| -> Self::Future {
- match result {
+ // Body parameters (note that non-required body parameters will ignore garbage
+ // values, rather than causing a 400 response). Produce warning header and logs for
+ // any unused fields.
+ let result = body.to_raw().await;
+ match result {
Ok(body) => {
let mut unused_elements = Vec::new();
let param_file_auto_batch: Option<models::FileAutoBatch> = if !body.is_empty() {
@@ -2662,29 +2680,28 @@ where
unused_elements.push(path.to_string());
}) {
Ok(param_file_auto_batch) => param_file_auto_batch,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse body parameter FileAutoBatch - doesn't match schema: {}", e)))
- .expect("Unable to create Bad Request response for invalid body parameter FileAutoBatch due to schema"))),
+ .expect("Unable to create Bad Request response for invalid body parameter FileAutoBatch due to schema")),
}
} else {
None
};
let param_file_auto_batch = match param_file_auto_batch {
Some(param_file_auto_batch) => param_file_auto_batch,
- None => return Box::new(future::ok(Response::builder()
+ None => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from("Missing required body parameter FileAutoBatch"))
- .expect("Unable to create Bad Request response for missing body parameter FileAutoBatch"))),
+ .expect("Unable to create Bad Request response for missing body parameter FileAutoBatch")),
};
- Box::new(
- api_impl.create_file_auto_batch(
+ let result = api_impl.create_file_auto_batch(
param_file_auto_batch,
&context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
+ ).await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
HeaderName::from_static("x-span-id"),
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
.expect("Unable to create X-Span-ID header value"));
@@ -2726,21 +2743,23 @@ where
www_authenticate
}
=> {
+ if let Some(www_authenticate) = www_authenticate {
let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
Ok(val) => val,
Err(e) => {
- return future::ok(Response::builder()
+ return Ok(Response::builder()
.status(StatusCode::INTERNAL_SERVER_ERROR)
.body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
.expect("Unable to create Internal Server Error for invalid response header"))
}
};
- *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
response.headers_mut().insert(
HeaderName::from_static("www_authenticate"),
www_authenticate
);
+ }
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
@@ -2790,64 +2809,59 @@ where
},
}
- future::ok(response)
- }
- ))
+ Ok(response)
},
- Err(e) => Box::new(future::ok(Response::builder()
+ Err(e) => Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't read body parameter FileAutoBatch: {}", e)))
- .expect("Unable to create Bad Request response due to unable to read body parameter FileAutoBatch"))),
+ .expect("Unable to create Bad Request response due to unable to read body parameter FileAutoBatch")),
}
- })
- ) as Self::Future
- }
+ }
- // CreateFileset - POST /editgroup/{editgroup_id}/fileset
- &hyper::Method::POST if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_FILESET) => {
- {
- let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
- &Some(ref authorization) => authorization,
- &None => {
- return Box::new(future::ok(
- Response::builder()
+ // CreateFileset - POST /editgroup/{editgroup_id}/fileset
+ &hyper::Method::POST if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_FILESET) => {
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>)
+ .get()
+ {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Ok(Response::builder()
.status(StatusCode::FORBIDDEN)
.body(Body::from("Unauthenticated"))
- .expect("Unable to create Authentication Forbidden response"),
- ))
- }
- };
- }
+ .expect("Unable to create Authentication Forbidden response"))
+ }
+ };
+ }
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_EDITGROUP_EDITGROUP_ID_FILESET
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID_FILESET in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID_FILESET.as_str())
);
- let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
Ok(param_editgroup_id) => param_editgroup_id,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- // Body parameters (note that non-required body parameters will ignore garbage
- // values, rather than causing a 400 response). Produce warning header and logs for
- // any unused fields.
- Box::new(body.concat2()
- .then(move |result| -> Self::Future {
- match result {
+ // Body parameters (note that non-required body parameters will ignore garbage
+ // values, rather than causing a 400 response). Produce warning header and logs for
+ // any unused fields.
+ let result = body.to_raw().await;
+ match result {
Ok(body) => {
let mut unused_elements = Vec::new();
let param_fileset_entity: Option<models::FilesetEntity> = if !body.is_empty() {
@@ -2857,30 +2871,29 @@ where
unused_elements.push(path.to_string());
}) {
Ok(param_fileset_entity) => param_fileset_entity,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse body parameter FilesetEntity - doesn't match schema: {}", e)))
- .expect("Unable to create Bad Request response for invalid body parameter FilesetEntity due to schema"))),
+ .expect("Unable to create Bad Request response for invalid body parameter FilesetEntity due to schema")),
}
} else {
None
};
let param_fileset_entity = match param_fileset_entity {
Some(param_fileset_entity) => param_fileset_entity,
- None => return Box::new(future::ok(Response::builder()
+ None => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from("Missing required body parameter FilesetEntity"))
- .expect("Unable to create Bad Request response for missing body parameter FilesetEntity"))),
+ .expect("Unable to create Bad Request response for missing body parameter FilesetEntity")),
};
- Box::new(
- api_impl.create_fileset(
+ let result = api_impl.create_fileset(
param_editgroup_id,
param_fileset_entity,
&context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
+ ).await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
HeaderName::from_static("x-span-id"),
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
.expect("Unable to create X-Span-ID header value"));
@@ -2922,21 +2935,23 @@ where
www_authenticate
}
=> {
+ if let Some(www_authenticate) = www_authenticate {
let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
Ok(val) => val,
Err(e) => {
- return future::ok(Response::builder()
+ return Ok(Response::builder()
.status(StatusCode::INTERNAL_SERVER_ERROR)
.body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
.expect("Unable to create Internal Server Error for invalid response header"))
}
};
- *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
response.headers_mut().insert(
HeaderName::from_static("www_authenticate"),
www_authenticate
);
+ }
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
@@ -2986,41 +3001,36 @@ where
},
}
- future::ok(response)
- }
- ))
+ Ok(response)
},
- Err(e) => Box::new(future::ok(Response::builder()
+ Err(e) => Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't read body parameter FilesetEntity: {}", e)))
- .expect("Unable to create Bad Request response due to unable to read body parameter FilesetEntity"))),
+ .expect("Unable to create Bad Request response due to unable to read body parameter FilesetEntity")),
}
- })
- ) as Self::Future
- }
+ }
- // CreateFilesetAutoBatch - POST /editgroup/auto/fileset/batch
- &hyper::Method::POST if path.matched(paths::ID_EDITGROUP_AUTO_FILESET_BATCH) => {
- {
- let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
- &Some(ref authorization) => authorization,
- &None => {
- return Box::new(future::ok(
- Response::builder()
+ // CreateFilesetAutoBatch - POST /editgroup/auto/fileset/batch
+ &hyper::Method::POST if path.matched(paths::ID_EDITGROUP_AUTO_FILESET_BATCH) => {
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>)
+ .get()
+ {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Ok(Response::builder()
.status(StatusCode::FORBIDDEN)
.body(Body::from("Unauthenticated"))
- .expect("Unable to create Authentication Forbidden response"),
- ))
- }
- };
- }
+ .expect("Unable to create Authentication Forbidden response"))
+ }
+ };
+ }
- // Body parameters (note that non-required body parameters will ignore garbage
- // values, rather than causing a 400 response). Produce warning header and logs for
- // any unused fields.
- Box::new(body.concat2()
- .then(move |result| -> Self::Future {
- match result {
+ // Body parameters (note that non-required body parameters will ignore garbage
+ // values, rather than causing a 400 response). Produce warning header and logs for
+ // any unused fields.
+ let result = body.to_raw().await;
+ match result {
Ok(body) => {
let mut unused_elements = Vec::new();
let param_fileset_auto_batch: Option<models::FilesetAutoBatch> = if !body.is_empty() {
@@ -3030,29 +3040,28 @@ where
unused_elements.push(path.to_string());
}) {
Ok(param_fileset_auto_batch) => param_fileset_auto_batch,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse body parameter FilesetAutoBatch - doesn't match schema: {}", e)))
- .expect("Unable to create Bad Request response for invalid body parameter FilesetAutoBatch due to schema"))),
+ .expect("Unable to create Bad Request response for invalid body parameter FilesetAutoBatch due to schema")),
}
} else {
None
};
let param_fileset_auto_batch = match param_fileset_auto_batch {
Some(param_fileset_auto_batch) => param_fileset_auto_batch,
- None => return Box::new(future::ok(Response::builder()
+ None => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from("Missing required body parameter FilesetAutoBatch"))
- .expect("Unable to create Bad Request response for missing body parameter FilesetAutoBatch"))),
+ .expect("Unable to create Bad Request response for missing body parameter FilesetAutoBatch")),
};
- Box::new(
- api_impl.create_fileset_auto_batch(
+ let result = api_impl.create_fileset_auto_batch(
param_fileset_auto_batch,
&context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
+ ).await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
HeaderName::from_static("x-span-id"),
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
.expect("Unable to create X-Span-ID header value"));
@@ -3094,21 +3103,23 @@ where
www_authenticate
}
=> {
+ if let Some(www_authenticate) = www_authenticate {
let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
Ok(val) => val,
Err(e) => {
- return future::ok(Response::builder()
+ return Ok(Response::builder()
.status(StatusCode::INTERNAL_SERVER_ERROR)
.body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
.expect("Unable to create Internal Server Error for invalid response header"))
}
};
- *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
response.headers_mut().insert(
HeaderName::from_static("www_authenticate"),
www_authenticate
);
+ }
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
@@ -3158,64 +3169,59 @@ where
},
}
- future::ok(response)
- }
- ))
+ Ok(response)
},
- Err(e) => Box::new(future::ok(Response::builder()
+ Err(e) => Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't read body parameter FilesetAutoBatch: {}", e)))
- .expect("Unable to create Bad Request response due to unable to read body parameter FilesetAutoBatch"))),
+ .expect("Unable to create Bad Request response due to unable to read body parameter FilesetAutoBatch")),
}
- })
- ) as Self::Future
- }
+ }
- // CreateRelease - POST /editgroup/{editgroup_id}/release
- &hyper::Method::POST if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_RELEASE) => {
- {
- let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
- &Some(ref authorization) => authorization,
- &None => {
- return Box::new(future::ok(
- Response::builder()
+ // CreateRelease - POST /editgroup/{editgroup_id}/release
+ &hyper::Method::POST if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_RELEASE) => {
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>)
+ .get()
+ {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Ok(Response::builder()
.status(StatusCode::FORBIDDEN)
.body(Body::from("Unauthenticated"))
- .expect("Unable to create Authentication Forbidden response"),
- ))
- }
- };
- }
+ .expect("Unable to create Authentication Forbidden response"))
+ }
+ };
+ }
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_EDITGROUP_EDITGROUP_ID_RELEASE
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID_RELEASE in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID_RELEASE.as_str())
);
- let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
Ok(param_editgroup_id) => param_editgroup_id,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- // Body parameters (note that non-required body parameters will ignore garbage
- // values, rather than causing a 400 response). Produce warning header and logs for
- // any unused fields.
- Box::new(body.concat2()
- .then(move |result| -> Self::Future {
- match result {
+ // Body parameters (note that non-required body parameters will ignore garbage
+ // values, rather than causing a 400 response). Produce warning header and logs for
+ // any unused fields.
+ let result = body.to_raw().await;
+ match result {
Ok(body) => {
let mut unused_elements = Vec::new();
let param_release_entity: Option<models::ReleaseEntity> = if !body.is_empty() {
@@ -3225,30 +3231,29 @@ where
unused_elements.push(path.to_string());
}) {
Ok(param_release_entity) => param_release_entity,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse body parameter ReleaseEntity - doesn't match schema: {}", e)))
- .expect("Unable to create Bad Request response for invalid body parameter ReleaseEntity due to schema"))),
+ .expect("Unable to create Bad Request response for invalid body parameter ReleaseEntity due to schema")),
}
} else {
None
};
let param_release_entity = match param_release_entity {
Some(param_release_entity) => param_release_entity,
- None => return Box::new(future::ok(Response::builder()
+ None => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from("Missing required body parameter ReleaseEntity"))
- .expect("Unable to create Bad Request response for missing body parameter ReleaseEntity"))),
+ .expect("Unable to create Bad Request response for missing body parameter ReleaseEntity")),
};
- Box::new(
- api_impl.create_release(
+ let result = api_impl.create_release(
param_editgroup_id,
param_release_entity,
&context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
+ ).await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
HeaderName::from_static("x-span-id"),
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
.expect("Unable to create X-Span-ID header value"));
@@ -3290,21 +3295,23 @@ where
www_authenticate
}
=> {
+ if let Some(www_authenticate) = www_authenticate {
let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
Ok(val) => val,
Err(e) => {
- return future::ok(Response::builder()
+ return Ok(Response::builder()
.status(StatusCode::INTERNAL_SERVER_ERROR)
.body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
.expect("Unable to create Internal Server Error for invalid response header"))
}
};
- *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
response.headers_mut().insert(
HeaderName::from_static("www_authenticate"),
www_authenticate
);
+ }
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
@@ -3354,41 +3361,36 @@ where
},
}
- future::ok(response)
- }
- ))
+ Ok(response)
},
- Err(e) => Box::new(future::ok(Response::builder()
+ Err(e) => Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't read body parameter ReleaseEntity: {}", e)))
- .expect("Unable to create Bad Request response due to unable to read body parameter ReleaseEntity"))),
+ .expect("Unable to create Bad Request response due to unable to read body parameter ReleaseEntity")),
}
- })
- ) as Self::Future
- }
+ }
- // CreateReleaseAutoBatch - POST /editgroup/auto/release/batch
- &hyper::Method::POST if path.matched(paths::ID_EDITGROUP_AUTO_RELEASE_BATCH) => {
- {
- let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
- &Some(ref authorization) => authorization,
- &None => {
- return Box::new(future::ok(
- Response::builder()
+ // CreateReleaseAutoBatch - POST /editgroup/auto/release/batch
+ &hyper::Method::POST if path.matched(paths::ID_EDITGROUP_AUTO_RELEASE_BATCH) => {
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>)
+ .get()
+ {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Ok(Response::builder()
.status(StatusCode::FORBIDDEN)
.body(Body::from("Unauthenticated"))
- .expect("Unable to create Authentication Forbidden response"),
- ))
- }
- };
- }
+ .expect("Unable to create Authentication Forbidden response"))
+ }
+ };
+ }
- // Body parameters (note that non-required body parameters will ignore garbage
- // values, rather than causing a 400 response). Produce warning header and logs for
- // any unused fields.
- Box::new(body.concat2()
- .then(move |result| -> Self::Future {
- match result {
+ // Body parameters (note that non-required body parameters will ignore garbage
+ // values, rather than causing a 400 response). Produce warning header and logs for
+ // any unused fields.
+ let result = body.to_raw().await;
+ match result {
Ok(body) => {
let mut unused_elements = Vec::new();
let param_release_auto_batch: Option<models::ReleaseAutoBatch> = if !body.is_empty() {
@@ -3398,29 +3400,28 @@ where
unused_elements.push(path.to_string());
}) {
Ok(param_release_auto_batch) => param_release_auto_batch,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse body parameter ReleaseAutoBatch - doesn't match schema: {}", e)))
- .expect("Unable to create Bad Request response for invalid body parameter ReleaseAutoBatch due to schema"))),
+ .expect("Unable to create Bad Request response for invalid body parameter ReleaseAutoBatch due to schema")),
}
} else {
None
};
let param_release_auto_batch = match param_release_auto_batch {
Some(param_release_auto_batch) => param_release_auto_batch,
- None => return Box::new(future::ok(Response::builder()
+ None => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from("Missing required body parameter ReleaseAutoBatch"))
- .expect("Unable to create Bad Request response for missing body parameter ReleaseAutoBatch"))),
+ .expect("Unable to create Bad Request response for missing body parameter ReleaseAutoBatch")),
};
- Box::new(
- api_impl.create_release_auto_batch(
+ let result = api_impl.create_release_auto_batch(
param_release_auto_batch,
&context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
+ ).await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
HeaderName::from_static("x-span-id"),
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
.expect("Unable to create X-Span-ID header value"));
@@ -3462,21 +3463,23 @@ where
www_authenticate
}
=> {
+ if let Some(www_authenticate) = www_authenticate {
let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
Ok(val) => val,
Err(e) => {
- return future::ok(Response::builder()
+ return Ok(Response::builder()
.status(StatusCode::INTERNAL_SERVER_ERROR)
.body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
.expect("Unable to create Internal Server Error for invalid response header"))
}
};
- *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
response.headers_mut().insert(
HeaderName::from_static("www_authenticate"),
www_authenticate
);
+ }
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
@@ -3526,64 +3529,61 @@ where
},
}
- future::ok(response)
- }
- ))
+ Ok(response)
},
- Err(e) => Box::new(future::ok(Response::builder()
+ Err(e) => Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't read body parameter ReleaseAutoBatch: {}", e)))
- .expect("Unable to create Bad Request response due to unable to read body parameter ReleaseAutoBatch"))),
+ .expect("Unable to create Bad Request response due to unable to read body parameter ReleaseAutoBatch")),
}
- })
- ) as Self::Future
- }
+ }
- // CreateWebcapture - POST /editgroup/{editgroup_id}/webcapture
- &hyper::Method::POST if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_WEBCAPTURE) => {
+ // CreateWebcapture - POST /editgroup/{editgroup_id}/webcapture
+ &hyper::Method::POST
+ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_WEBCAPTURE) =>
{
- let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
- &Some(ref authorization) => authorization,
- &None => {
- return Box::new(future::ok(
- Response::builder()
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>)
+ .get()
+ {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Ok(Response::builder()
.status(StatusCode::FORBIDDEN)
.body(Body::from("Unauthenticated"))
- .expect("Unable to create Authentication Forbidden response"),
- ))
- }
- };
- }
+ .expect("Unable to create Authentication Forbidden response"))
+ }
+ };
+ }
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_EDITGROUP_EDITGROUP_ID_WEBCAPTURE
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID_WEBCAPTURE in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID_WEBCAPTURE.as_str())
);
- let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
Ok(param_editgroup_id) => param_editgroup_id,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- // Body parameters (note that non-required body parameters will ignore garbage
- // values, rather than causing a 400 response). Produce warning header and logs for
- // any unused fields.
- Box::new(body.concat2()
- .then(move |result| -> Self::Future {
- match result {
+ // Body parameters (note that non-required body parameters will ignore garbage
+ // values, rather than causing a 400 response). Produce warning header and logs for
+ // any unused fields.
+ let result = body.to_raw().await;
+ match result {
Ok(body) => {
let mut unused_elements = Vec::new();
let param_webcapture_entity: Option<models::WebcaptureEntity> = if !body.is_empty() {
@@ -3593,30 +3593,29 @@ where
unused_elements.push(path.to_string());
}) {
Ok(param_webcapture_entity) => param_webcapture_entity,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse body parameter WebcaptureEntity - doesn't match schema: {}", e)))
- .expect("Unable to create Bad Request response for invalid body parameter WebcaptureEntity due to schema"))),
+ .expect("Unable to create Bad Request response for invalid body parameter WebcaptureEntity due to schema")),
}
} else {
None
};
let param_webcapture_entity = match param_webcapture_entity {
Some(param_webcapture_entity) => param_webcapture_entity,
- None => return Box::new(future::ok(Response::builder()
+ None => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from("Missing required body parameter WebcaptureEntity"))
- .expect("Unable to create Bad Request response for missing body parameter WebcaptureEntity"))),
+ .expect("Unable to create Bad Request response for missing body parameter WebcaptureEntity")),
};
- Box::new(
- api_impl.create_webcapture(
+ let result = api_impl.create_webcapture(
param_editgroup_id,
param_webcapture_entity,
&context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
+ ).await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
HeaderName::from_static("x-span-id"),
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
.expect("Unable to create X-Span-ID header value"));
@@ -3658,21 +3657,23 @@ where
www_authenticate
}
=> {
+ if let Some(www_authenticate) = www_authenticate {
let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
Ok(val) => val,
Err(e) => {
- return future::ok(Response::builder()
+ return Ok(Response::builder()
.status(StatusCode::INTERNAL_SERVER_ERROR)
.body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
.expect("Unable to create Internal Server Error for invalid response header"))
}
};
- *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
response.headers_mut().insert(
HeaderName::from_static("www_authenticate"),
www_authenticate
);
+ }
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
@@ -3722,41 +3723,36 @@ where
},
}
- future::ok(response)
- }
- ))
+ Ok(response)
},
- Err(e) => Box::new(future::ok(Response::builder()
+ Err(e) => Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't read body parameter WebcaptureEntity: {}", e)))
- .expect("Unable to create Bad Request response due to unable to read body parameter WebcaptureEntity"))),
+ .expect("Unable to create Bad Request response due to unable to read body parameter WebcaptureEntity")),
}
- })
- ) as Self::Future
- }
+ }
- // CreateWebcaptureAutoBatch - POST /editgroup/auto/webcapture/batch
- &hyper::Method::POST if path.matched(paths::ID_EDITGROUP_AUTO_WEBCAPTURE_BATCH) => {
- {
- let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
- &Some(ref authorization) => authorization,
- &None => {
- return Box::new(future::ok(
- Response::builder()
+ // CreateWebcaptureAutoBatch - POST /editgroup/auto/webcapture/batch
+ &hyper::Method::POST if path.matched(paths::ID_EDITGROUP_AUTO_WEBCAPTURE_BATCH) => {
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>)
+ .get()
+ {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Ok(Response::builder()
.status(StatusCode::FORBIDDEN)
.body(Body::from("Unauthenticated"))
- .expect("Unable to create Authentication Forbidden response"),
- ))
- }
- };
- }
+ .expect("Unable to create Authentication Forbidden response"))
+ }
+ };
+ }
- // Body parameters (note that non-required body parameters will ignore garbage
- // values, rather than causing a 400 response). Produce warning header and logs for
- // any unused fields.
- Box::new(body.concat2()
- .then(move |result| -> Self::Future {
- match result {
+ // Body parameters (note that non-required body parameters will ignore garbage
+ // values, rather than causing a 400 response). Produce warning header and logs for
+ // any unused fields.
+ let result = body.to_raw().await;
+ match result {
Ok(body) => {
let mut unused_elements = Vec::new();
let param_webcapture_auto_batch: Option<models::WebcaptureAutoBatch> = if !body.is_empty() {
@@ -3766,29 +3762,28 @@ where
unused_elements.push(path.to_string());
}) {
Ok(param_webcapture_auto_batch) => param_webcapture_auto_batch,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse body parameter WebcaptureAutoBatch - doesn't match schema: {}", e)))
- .expect("Unable to create Bad Request response for invalid body parameter WebcaptureAutoBatch due to schema"))),
+ .expect("Unable to create Bad Request response for invalid body parameter WebcaptureAutoBatch due to schema")),
}
} else {
None
};
let param_webcapture_auto_batch = match param_webcapture_auto_batch {
Some(param_webcapture_auto_batch) => param_webcapture_auto_batch,
- None => return Box::new(future::ok(Response::builder()
+ None => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from("Missing required body parameter WebcaptureAutoBatch"))
- .expect("Unable to create Bad Request response for missing body parameter WebcaptureAutoBatch"))),
+ .expect("Unable to create Bad Request response for missing body parameter WebcaptureAutoBatch")),
};
- Box::new(
- api_impl.create_webcapture_auto_batch(
+ let result = api_impl.create_webcapture_auto_batch(
param_webcapture_auto_batch,
&context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
+ ).await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
HeaderName::from_static("x-span-id"),
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
.expect("Unable to create X-Span-ID header value"));
@@ -3830,21 +3825,23 @@ where
www_authenticate
}
=> {
+ if let Some(www_authenticate) = www_authenticate {
let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
Ok(val) => val,
Err(e) => {
- return future::ok(Response::builder()
+ return Ok(Response::builder()
.status(StatusCode::INTERNAL_SERVER_ERROR)
.body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
.expect("Unable to create Internal Server Error for invalid response header"))
}
};
- *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
response.headers_mut().insert(
HeaderName::from_static("www_authenticate"),
www_authenticate
);
+ }
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
@@ -3894,64 +3891,59 @@ where
},
}
- future::ok(response)
- }
- ))
+ Ok(response)
},
- Err(e) => Box::new(future::ok(Response::builder()
+ Err(e) => Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't read body parameter WebcaptureAutoBatch: {}", e)))
- .expect("Unable to create Bad Request response due to unable to read body parameter WebcaptureAutoBatch"))),
+ .expect("Unable to create Bad Request response due to unable to read body parameter WebcaptureAutoBatch")),
}
- })
- ) as Self::Future
- }
+ }
- // CreateWork - POST /editgroup/{editgroup_id}/work
- &hyper::Method::POST if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_WORK) => {
- {
- let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
- &Some(ref authorization) => authorization,
- &None => {
- return Box::new(future::ok(
- Response::builder()
+ // CreateWork - POST /editgroup/{editgroup_id}/work
+ &hyper::Method::POST if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_WORK) => {
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>)
+ .get()
+ {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Ok(Response::builder()
.status(StatusCode::FORBIDDEN)
.body(Body::from("Unauthenticated"))
- .expect("Unable to create Authentication Forbidden response"),
- ))
- }
- };
- }
+ .expect("Unable to create Authentication Forbidden response"))
+ }
+ };
+ }
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_EDITGROUP_EDITGROUP_ID_WORK
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID_WORK in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID_WORK.as_str())
);
- let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
Ok(param_editgroup_id) => param_editgroup_id,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- // Body parameters (note that non-required body parameters will ignore garbage
- // values, rather than causing a 400 response). Produce warning header and logs for
- // any unused fields.
- Box::new(body.concat2()
- .then(move |result| -> Self::Future {
- match result {
+ // Body parameters (note that non-required body parameters will ignore garbage
+ // values, rather than causing a 400 response). Produce warning header and logs for
+ // any unused fields.
+ let result = body.to_raw().await;
+ match result {
Ok(body) => {
let mut unused_elements = Vec::new();
let param_work_entity: Option<models::WorkEntity> = if !body.is_empty() {
@@ -3961,30 +3953,29 @@ where
unused_elements.push(path.to_string());
}) {
Ok(param_work_entity) => param_work_entity,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse body parameter WorkEntity - doesn't match schema: {}", e)))
- .expect("Unable to create Bad Request response for invalid body parameter WorkEntity due to schema"))),
+ .expect("Unable to create Bad Request response for invalid body parameter WorkEntity due to schema")),
}
} else {
None
};
let param_work_entity = match param_work_entity {
Some(param_work_entity) => param_work_entity,
- None => return Box::new(future::ok(Response::builder()
+ None => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from("Missing required body parameter WorkEntity"))
- .expect("Unable to create Bad Request response for missing body parameter WorkEntity"))),
+ .expect("Unable to create Bad Request response for missing body parameter WorkEntity")),
};
- Box::new(
- api_impl.create_work(
+ let result = api_impl.create_work(
param_editgroup_id,
param_work_entity,
&context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
+ ).await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
HeaderName::from_static("x-span-id"),
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
.expect("Unable to create X-Span-ID header value"));
@@ -4026,21 +4017,23 @@ where
www_authenticate
}
=> {
+ if let Some(www_authenticate) = www_authenticate {
let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
Ok(val) => val,
Err(e) => {
- return future::ok(Response::builder()
+ return Ok(Response::builder()
.status(StatusCode::INTERNAL_SERVER_ERROR)
.body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
.expect("Unable to create Internal Server Error for invalid response header"))
}
};
- *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
response.headers_mut().insert(
HeaderName::from_static("www_authenticate"),
www_authenticate
);
+ }
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
@@ -4090,41 +4083,36 @@ where
},
}
- future::ok(response)
- }
- ))
+ Ok(response)
},
- Err(e) => Box::new(future::ok(Response::builder()
+ Err(e) => Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't read body parameter WorkEntity: {}", e)))
- .expect("Unable to create Bad Request response due to unable to read body parameter WorkEntity"))),
+ .expect("Unable to create Bad Request response due to unable to read body parameter WorkEntity")),
}
- })
- ) as Self::Future
- }
+ }
- // CreateWorkAutoBatch - POST /editgroup/auto/work/batch
- &hyper::Method::POST if path.matched(paths::ID_EDITGROUP_AUTO_WORK_BATCH) => {
- {
- let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
- &Some(ref authorization) => authorization,
- &None => {
- return Box::new(future::ok(
- Response::builder()
+ // CreateWorkAutoBatch - POST /editgroup/auto/work/batch
+ &hyper::Method::POST if path.matched(paths::ID_EDITGROUP_AUTO_WORK_BATCH) => {
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>)
+ .get()
+ {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Ok(Response::builder()
.status(StatusCode::FORBIDDEN)
.body(Body::from("Unauthenticated"))
- .expect("Unable to create Authentication Forbidden response"),
- ))
- }
- };
- }
+ .expect("Unable to create Authentication Forbidden response"))
+ }
+ };
+ }
- // Body parameters (note that non-required body parameters will ignore garbage
- // values, rather than causing a 400 response). Produce warning header and logs for
- // any unused fields.
- Box::new(body.concat2()
- .then(move |result| -> Self::Future {
- match result {
+ // Body parameters (note that non-required body parameters will ignore garbage
+ // values, rather than causing a 400 response). Produce warning header and logs for
+ // any unused fields.
+ let result = body.to_raw().await;
+ match result {
Ok(body) => {
let mut unused_elements = Vec::new();
let param_work_auto_batch: Option<models::WorkAutoBatch> = if !body.is_empty() {
@@ -4134,29 +4122,28 @@ where
unused_elements.push(path.to_string());
}) {
Ok(param_work_auto_batch) => param_work_auto_batch,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse body parameter WorkAutoBatch - doesn't match schema: {}", e)))
- .expect("Unable to create Bad Request response for invalid body parameter WorkAutoBatch due to schema"))),
+ .expect("Unable to create Bad Request response for invalid body parameter WorkAutoBatch due to schema")),
}
} else {
None
};
let param_work_auto_batch = match param_work_auto_batch {
Some(param_work_auto_batch) => param_work_auto_batch,
- None => return Box::new(future::ok(Response::builder()
+ None => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from("Missing required body parameter WorkAutoBatch"))
- .expect("Unable to create Bad Request response for missing body parameter WorkAutoBatch"))),
+ .expect("Unable to create Bad Request response for missing body parameter WorkAutoBatch")),
};
- Box::new(
- api_impl.create_work_auto_batch(
+ let result = api_impl.create_work_auto_batch(
param_work_auto_batch,
&context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
+ ).await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
HeaderName::from_static("x-span-id"),
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
.expect("Unable to create X-Span-ID header value"));
@@ -4198,21 +4185,23 @@ where
www_authenticate
}
=> {
+ if let Some(www_authenticate) = www_authenticate {
let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
Ok(val) => val,
Err(e) => {
- return future::ok(Response::builder()
+ return Ok(Response::builder()
.status(StatusCode::INTERNAL_SERVER_ERROR)
.body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
.expect("Unable to create Internal Server Error for invalid response header"))
}
};
- *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
response.headers_mut().insert(
HeaderName::from_static("www_authenticate"),
www_authenticate
);
+ }
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
@@ -4262,8430 +4251,9286 @@ where
},
}
- future::ok(response)
- }
- ))
+ Ok(response)
},
- Err(e) => Box::new(future::ok(Response::builder()
+ Err(e) => Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't read body parameter WorkAutoBatch: {}", e)))
- .expect("Unable to create Bad Request response due to unable to read body parameter WorkAutoBatch"))),
+ .expect("Unable to create Bad Request response due to unable to read body parameter WorkAutoBatch")),
}
- })
- ) as Self::Future
- }
+ }
- // DeleteContainer - DELETE /editgroup/{editgroup_id}/container/{ident}
- &hyper::Method::DELETE
- if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_CONTAINER_IDENT) =>
- {
+ // DeleteContainer - DELETE /editgroup/{editgroup_id}/container/{ident}
+ &hyper::Method::DELETE
+ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_CONTAINER_IDENT) =>
{
- let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
- &Some(ref authorization) => authorization,
- &None => {
- return Box::new(future::ok(
- Response::builder()
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>)
+ .get()
+ {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Ok(Response::builder()
.status(StatusCode::FORBIDDEN)
.body(Body::from("Unauthenticated"))
- .expect("Unable to create Authentication Forbidden response"),
- ))
- }
- };
- }
+ .expect("Unable to create Authentication Forbidden response"))
+ }
+ };
+ }
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_EDITGROUP_EDITGROUP_ID_CONTAINER_IDENT
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID_CONTAINER_IDENT in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID_CONTAINER_IDENT.as_str())
);
- let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
Ok(param_editgroup_id) => param_editgroup_id,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
Ok(param_ident) => match param_ident.parse::<String>() {
Ok(param_ident) => param_ident,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- Box::new({
- {
- {
- Box::new(
- api_impl.delete_container(
- param_editgroup_id,
- param_ident,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ let result = api_impl
+ .delete_container(param_editgroup_id, param_ident, &context)
+ .await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
- match result {
- Ok(rsp) => match rsp {
- DeleteContainerResponse::DeletedEntity
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ match result {
+ Ok(rsp) => match rsp {
+ DeleteContainerResponse::DeletedEntity(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_CONTAINER_DELETED_ENTITY"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteContainerResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteContainerResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_CONTAINER_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteContainerResponse::NotAuthorized
- {
- body,
- www_authenticate
- }
- => {
- let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteContainerResponse::NotAuthorized {
+ body,
+ www_authenticate,
+ } => {
+ if let Some(www_authenticate) = www_authenticate {
+ let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
Ok(val) => val,
Err(e) => {
- return future::ok(Response::builder()
+ return Ok(Response::builder()
.status(StatusCode::INTERNAL_SERVER_ERROR)
.body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
.expect("Unable to create Internal Server Error for invalid response header"))
}
};
- *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
- response.headers_mut().insert(
- HeaderName::from_static("www_authenticate"),
- www_authenticate
- );
- response.headers_mut().insert(
+ response.headers_mut().insert(
+ HeaderName::from_static("www_authenticate"),
+ www_authenticate,
+ );
+ }
+ *response.status_mut() = StatusCode::from_u16(401)
+ .expect("Unable to turn 401 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_CONTAINER_NOT_AUTHORIZED"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteContainerResponse::Forbidden
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(403).expect("Unable to turn 403 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteContainerResponse::Forbidden(body) => {
+ *response.status_mut() = StatusCode::from_u16(403)
+ .expect("Unable to turn 403 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_CONTAINER_FORBIDDEN"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteContainerResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteContainerResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_CONTAINER_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteContainerResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteContainerResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_CONTAINER_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // DeleteContainerEdit - DELETE /editgroup/{editgroup_id}/container/edit/{edit_id}
- &hyper::Method::DELETE
- if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_CONTAINER_EDIT_EDIT_ID) =>
- {
+ Ok(response)
+ }
+
+ // DeleteContainerEdit - DELETE /editgroup/{editgroup_id}/container/edit/{edit_id}
+ &hyper::Method::DELETE
+ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_CONTAINER_EDIT_EDIT_ID) =>
{
- let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
- &Some(ref authorization) => authorization,
- &None => {
- return Box::new(future::ok(
- Response::builder()
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>)
+ .get()
+ {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Ok(Response::builder()
.status(StatusCode::FORBIDDEN)
.body(Body::from("Unauthenticated"))
- .expect("Unable to create Authentication Forbidden response"),
- ))
- }
- };
- }
+ .expect("Unable to create Authentication Forbidden response"))
+ }
+ };
+ }
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_EDITGROUP_EDITGROUP_ID_CONTAINER_EDIT_EDIT_ID
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID_CONTAINER_EDIT_EDIT_ID in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID_CONTAINER_EDIT_EDIT_ID.as_str())
);
- let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
Ok(param_editgroup_id) => param_editgroup_id,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- let param_edit_id = match percent_encoding::percent_decode(path_params["edit_id"].as_bytes()).decode_utf8() {
+ let param_edit_id = match percent_encoding::percent_decode(path_params["edit_id"].as_bytes()).decode_utf8() {
Ok(param_edit_id) => match param_edit_id.parse::<String>() {
Ok(param_edit_id) => param_edit_id,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter edit_id: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["edit_id"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- Box::new({
- {
- {
- Box::new(
- api_impl.delete_container_edit(
- param_editgroup_id,
- param_edit_id,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ let result = api_impl
+ .delete_container_edit(param_editgroup_id, param_edit_id, &context)
+ .await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
- match result {
- Ok(rsp) => match rsp {
- DeleteContainerEditResponse::DeletedEdit
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ match result {
+ Ok(rsp) => match rsp {
+ DeleteContainerEditResponse::DeletedEdit(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_CONTAINER_EDIT_DELETED_EDIT"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteContainerEditResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteContainerEditResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_CONTAINER_EDIT_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteContainerEditResponse::NotAuthorized
- {
- body,
- www_authenticate
- }
- => {
- let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteContainerEditResponse::NotAuthorized {
+ body,
+ www_authenticate,
+ } => {
+ if let Some(www_authenticate) = www_authenticate {
+ let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
Ok(val) => val,
Err(e) => {
- return future::ok(Response::builder()
+ return Ok(Response::builder()
.status(StatusCode::INTERNAL_SERVER_ERROR)
.body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
.expect("Unable to create Internal Server Error for invalid response header"))
}
};
- *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
- response.headers_mut().insert(
- HeaderName::from_static("www_authenticate"),
- www_authenticate
- );
- response.headers_mut().insert(
+ response.headers_mut().insert(
+ HeaderName::from_static("www_authenticate"),
+ www_authenticate,
+ );
+ }
+ *response.status_mut() = StatusCode::from_u16(401)
+ .expect("Unable to turn 401 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_CONTAINER_EDIT_NOT_AUTHORIZED"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteContainerEditResponse::Forbidden
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(403).expect("Unable to turn 403 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteContainerEditResponse::Forbidden(body) => {
+ *response.status_mut() = StatusCode::from_u16(403)
+ .expect("Unable to turn 403 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_CONTAINER_EDIT_FORBIDDEN"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteContainerEditResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteContainerEditResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_CONTAINER_EDIT_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteContainerEditResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteContainerEditResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_CONTAINER_EDIT_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // DeleteCreator - DELETE /editgroup/{editgroup_id}/creator/{ident}
- &hyper::Method::DELETE
- if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_CREATOR_IDENT) =>
- {
+ Ok(response)
+ }
+
+ // DeleteCreator - DELETE /editgroup/{editgroup_id}/creator/{ident}
+ &hyper::Method::DELETE
+ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_CREATOR_IDENT) =>
{
- let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
- &Some(ref authorization) => authorization,
- &None => {
- return Box::new(future::ok(
- Response::builder()
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>)
+ .get()
+ {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Ok(Response::builder()
.status(StatusCode::FORBIDDEN)
.body(Body::from("Unauthenticated"))
- .expect("Unable to create Authentication Forbidden response"),
- ))
- }
- };
- }
+ .expect("Unable to create Authentication Forbidden response"))
+ }
+ };
+ }
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_EDITGROUP_EDITGROUP_ID_CREATOR_IDENT
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID_CREATOR_IDENT in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID_CREATOR_IDENT.as_str())
);
- let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
Ok(param_editgroup_id) => param_editgroup_id,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
Ok(param_ident) => match param_ident.parse::<String>() {
Ok(param_ident) => param_ident,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- Box::new({
- {
- {
- Box::new(
- api_impl.delete_creator(
- param_editgroup_id,
- param_ident,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ let result = api_impl
+ .delete_creator(param_editgroup_id, param_ident, &context)
+ .await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
- match result {
- Ok(rsp) => match rsp {
- DeleteCreatorResponse::DeletedEntity
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ match result {
+ Ok(rsp) => match rsp {
+ DeleteCreatorResponse::DeletedEntity(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_CREATOR_DELETED_ENTITY"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteCreatorResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteCreatorResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_CREATOR_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteCreatorResponse::NotAuthorized
- {
- body,
- www_authenticate
- }
- => {
- let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteCreatorResponse::NotAuthorized {
+ body,
+ www_authenticate,
+ } => {
+ if let Some(www_authenticate) = www_authenticate {
+ let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
Ok(val) => val,
Err(e) => {
- return future::ok(Response::builder()
+ return Ok(Response::builder()
.status(StatusCode::INTERNAL_SERVER_ERROR)
.body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
.expect("Unable to create Internal Server Error for invalid response header"))
}
};
- *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
- response.headers_mut().insert(
- HeaderName::from_static("www_authenticate"),
- www_authenticate
- );
- response.headers_mut().insert(
+ response.headers_mut().insert(
+ HeaderName::from_static("www_authenticate"),
+ www_authenticate,
+ );
+ }
+ *response.status_mut() = StatusCode::from_u16(401)
+ .expect("Unable to turn 401 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_CREATOR_NOT_AUTHORIZED"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteCreatorResponse::Forbidden
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(403).expect("Unable to turn 403 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteCreatorResponse::Forbidden(body) => {
+ *response.status_mut() = StatusCode::from_u16(403)
+ .expect("Unable to turn 403 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_CREATOR_FORBIDDEN"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteCreatorResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteCreatorResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_CREATOR_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteCreatorResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteCreatorResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_CREATOR_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // DeleteCreatorEdit - DELETE /editgroup/{editgroup_id}/creator/edit/{edit_id}
- &hyper::Method::DELETE
- if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_CREATOR_EDIT_EDIT_ID) =>
- {
+ Ok(response)
+ }
+
+ // DeleteCreatorEdit - DELETE /editgroup/{editgroup_id}/creator/edit/{edit_id}
+ &hyper::Method::DELETE
+ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_CREATOR_EDIT_EDIT_ID) =>
{
- let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
- &Some(ref authorization) => authorization,
- &None => {
- return Box::new(future::ok(
- Response::builder()
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>)
+ .get()
+ {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Ok(Response::builder()
.status(StatusCode::FORBIDDEN)
.body(Body::from("Unauthenticated"))
- .expect("Unable to create Authentication Forbidden response"),
- ))
- }
- };
- }
+ .expect("Unable to create Authentication Forbidden response"))
+ }
+ };
+ }
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_EDITGROUP_EDITGROUP_ID_CREATOR_EDIT_EDIT_ID
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID_CREATOR_EDIT_EDIT_ID in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID_CREATOR_EDIT_EDIT_ID.as_str())
);
- let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
Ok(param_editgroup_id) => param_editgroup_id,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- let param_edit_id = match percent_encoding::percent_decode(path_params["edit_id"].as_bytes()).decode_utf8() {
+ let param_edit_id = match percent_encoding::percent_decode(path_params["edit_id"].as_bytes()).decode_utf8() {
Ok(param_edit_id) => match param_edit_id.parse::<String>() {
Ok(param_edit_id) => param_edit_id,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter edit_id: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["edit_id"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- Box::new({
- {
- {
- Box::new(
- api_impl.delete_creator_edit(
- param_editgroup_id,
- param_edit_id,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ let result = api_impl
+ .delete_creator_edit(param_editgroup_id, param_edit_id, &context)
+ .await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
- match result {
- Ok(rsp) => match rsp {
- DeleteCreatorEditResponse::DeletedEdit
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ match result {
+ Ok(rsp) => match rsp {
+ DeleteCreatorEditResponse::DeletedEdit(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_CREATOR_EDIT_DELETED_EDIT"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteCreatorEditResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteCreatorEditResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_CREATOR_EDIT_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteCreatorEditResponse::NotAuthorized
- {
- body,
- www_authenticate
- }
- => {
- let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteCreatorEditResponse::NotAuthorized {
+ body,
+ www_authenticate,
+ } => {
+ if let Some(www_authenticate) = www_authenticate {
+ let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
Ok(val) => val,
Err(e) => {
- return future::ok(Response::builder()
+ return Ok(Response::builder()
.status(StatusCode::INTERNAL_SERVER_ERROR)
.body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
.expect("Unable to create Internal Server Error for invalid response header"))
}
};
- *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
- response.headers_mut().insert(
- HeaderName::from_static("www_authenticate"),
- www_authenticate
- );
- response.headers_mut().insert(
+ response.headers_mut().insert(
+ HeaderName::from_static("www_authenticate"),
+ www_authenticate,
+ );
+ }
+ *response.status_mut() = StatusCode::from_u16(401)
+ .expect("Unable to turn 401 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_CREATOR_EDIT_NOT_AUTHORIZED"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteCreatorEditResponse::Forbidden
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(403).expect("Unable to turn 403 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteCreatorEditResponse::Forbidden(body) => {
+ *response.status_mut() = StatusCode::from_u16(403)
+ .expect("Unable to turn 403 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_CREATOR_EDIT_FORBIDDEN"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteCreatorEditResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteCreatorEditResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_CREATOR_EDIT_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteCreatorEditResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteCreatorEditResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_CREATOR_EDIT_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // DeleteFile - DELETE /editgroup/{editgroup_id}/file/{ident}
- &hyper::Method::DELETE if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_FILE_IDENT) => {
+ Ok(response)
+ }
+
+ // DeleteFile - DELETE /editgroup/{editgroup_id}/file/{ident}
+ &hyper::Method::DELETE
+ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_FILE_IDENT) =>
{
- let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
- &Some(ref authorization) => authorization,
- &None => {
- return Box::new(future::ok(
- Response::builder()
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>)
+ .get()
+ {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Ok(Response::builder()
.status(StatusCode::FORBIDDEN)
.body(Body::from("Unauthenticated"))
- .expect("Unable to create Authentication Forbidden response"),
- ))
- }
- };
- }
+ .expect("Unable to create Authentication Forbidden response"))
+ }
+ };
+ }
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_EDITGROUP_EDITGROUP_ID_FILE_IDENT
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID_FILE_IDENT in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID_FILE_IDENT.as_str())
);
- let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
Ok(param_editgroup_id) => param_editgroup_id,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
Ok(param_ident) => match param_ident.parse::<String>() {
Ok(param_ident) => param_ident,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- Box::new({
- {
- {
- Box::new(
- api_impl.delete_file(
- param_editgroup_id,
- param_ident,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ let result = api_impl
+ .delete_file(param_editgroup_id, param_ident, &context)
+ .await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
- match result {
- Ok(rsp) => match rsp {
- DeleteFileResponse::DeletedEntity
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ match result {
+ Ok(rsp) => match rsp {
+ DeleteFileResponse::DeletedEntity(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_FILE_DELETED_ENTITY"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteFileResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteFileResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_FILE_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteFileResponse::NotAuthorized
- {
- body,
- www_authenticate
- }
- => {
- let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteFileResponse::NotAuthorized {
+ body,
+ www_authenticate,
+ } => {
+ if let Some(www_authenticate) = www_authenticate {
+ let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
Ok(val) => val,
Err(e) => {
- return future::ok(Response::builder()
+ return Ok(Response::builder()
.status(StatusCode::INTERNAL_SERVER_ERROR)
.body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
.expect("Unable to create Internal Server Error for invalid response header"))
}
};
- *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
- response.headers_mut().insert(
- HeaderName::from_static("www_authenticate"),
- www_authenticate
- );
- response.headers_mut().insert(
+ response.headers_mut().insert(
+ HeaderName::from_static("www_authenticate"),
+ www_authenticate,
+ );
+ }
+ *response.status_mut() = StatusCode::from_u16(401)
+ .expect("Unable to turn 401 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_FILE_NOT_AUTHORIZED"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteFileResponse::Forbidden
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(403).expect("Unable to turn 403 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteFileResponse::Forbidden(body) => {
+ *response.status_mut() = StatusCode::from_u16(403)
+ .expect("Unable to turn 403 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_FILE_FORBIDDEN"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteFileResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteFileResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_FILE_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteFileResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteFileResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_FILE_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // DeleteFileEdit - DELETE /editgroup/{editgroup_id}/file/edit/{edit_id}
- &hyper::Method::DELETE
- if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_FILE_EDIT_EDIT_ID) =>
- {
+ Ok(response)
+ }
+
+ // DeleteFileEdit - DELETE /editgroup/{editgroup_id}/file/edit/{edit_id}
+ &hyper::Method::DELETE
+ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_FILE_EDIT_EDIT_ID) =>
{
- let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
- &Some(ref authorization) => authorization,
- &None => {
- return Box::new(future::ok(
- Response::builder()
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>)
+ .get()
+ {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Ok(Response::builder()
.status(StatusCode::FORBIDDEN)
.body(Body::from("Unauthenticated"))
- .expect("Unable to create Authentication Forbidden response"),
- ))
- }
- };
- }
+ .expect("Unable to create Authentication Forbidden response"))
+ }
+ };
+ }
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_EDITGROUP_EDITGROUP_ID_FILE_EDIT_EDIT_ID
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID_FILE_EDIT_EDIT_ID in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID_FILE_EDIT_EDIT_ID.as_str())
);
- let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
Ok(param_editgroup_id) => param_editgroup_id,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- let param_edit_id = match percent_encoding::percent_decode(path_params["edit_id"].as_bytes()).decode_utf8() {
+ let param_edit_id = match percent_encoding::percent_decode(path_params["edit_id"].as_bytes()).decode_utf8() {
Ok(param_edit_id) => match param_edit_id.parse::<String>() {
Ok(param_edit_id) => param_edit_id,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter edit_id: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["edit_id"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- Box::new({
- {
- {
- Box::new(
- api_impl.delete_file_edit(
- param_editgroup_id,
- param_edit_id,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ let result = api_impl
+ .delete_file_edit(param_editgroup_id, param_edit_id, &context)
+ .await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
- match result {
- Ok(rsp) => match rsp {
- DeleteFileEditResponse::DeletedEdit
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ match result {
+ Ok(rsp) => match rsp {
+ DeleteFileEditResponse::DeletedEdit(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_FILE_EDIT_DELETED_EDIT"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteFileEditResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteFileEditResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_FILE_EDIT_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteFileEditResponse::NotAuthorized
- {
- body,
- www_authenticate
- }
- => {
- let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteFileEditResponse::NotAuthorized {
+ body,
+ www_authenticate,
+ } => {
+ if let Some(www_authenticate) = www_authenticate {
+ let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
Ok(val) => val,
Err(e) => {
- return future::ok(Response::builder()
+ return Ok(Response::builder()
.status(StatusCode::INTERNAL_SERVER_ERROR)
.body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
.expect("Unable to create Internal Server Error for invalid response header"))
}
};
- *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
- response.headers_mut().insert(
- HeaderName::from_static("www_authenticate"),
- www_authenticate
- );
- response.headers_mut().insert(
+ response.headers_mut().insert(
+ HeaderName::from_static("www_authenticate"),
+ www_authenticate,
+ );
+ }
+ *response.status_mut() = StatusCode::from_u16(401)
+ .expect("Unable to turn 401 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_FILE_EDIT_NOT_AUTHORIZED"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteFileEditResponse::Forbidden
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(403).expect("Unable to turn 403 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteFileEditResponse::Forbidden(body) => {
+ *response.status_mut() = StatusCode::from_u16(403)
+ .expect("Unable to turn 403 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_FILE_EDIT_FORBIDDEN"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteFileEditResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteFileEditResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_FILE_EDIT_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteFileEditResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteFileEditResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_FILE_EDIT_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // DeleteFileset - DELETE /editgroup/{editgroup_id}/fileset/{ident}
- &hyper::Method::DELETE
- if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_FILESET_IDENT) =>
- {
+ Ok(response)
+ }
+
+ // DeleteFileset - DELETE /editgroup/{editgroup_id}/fileset/{ident}
+ &hyper::Method::DELETE
+ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_FILESET_IDENT) =>
{
- let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
- &Some(ref authorization) => authorization,
- &None => {
- return Box::new(future::ok(
- Response::builder()
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>)
+ .get()
+ {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Ok(Response::builder()
.status(StatusCode::FORBIDDEN)
.body(Body::from("Unauthenticated"))
- .expect("Unable to create Authentication Forbidden response"),
- ))
- }
- };
- }
+ .expect("Unable to create Authentication Forbidden response"))
+ }
+ };
+ }
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_EDITGROUP_EDITGROUP_ID_FILESET_IDENT
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID_FILESET_IDENT in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID_FILESET_IDENT.as_str())
);
- let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
Ok(param_editgroup_id) => param_editgroup_id,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
Ok(param_ident) => match param_ident.parse::<String>() {
Ok(param_ident) => param_ident,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- Box::new({
- {
- {
- Box::new(
- api_impl.delete_fileset(
- param_editgroup_id,
- param_ident,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ let result = api_impl
+ .delete_fileset(param_editgroup_id, param_ident, &context)
+ .await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
- match result {
- Ok(rsp) => match rsp {
- DeleteFilesetResponse::DeletedEntity
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ match result {
+ Ok(rsp) => match rsp {
+ DeleteFilesetResponse::DeletedEntity(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_FILESET_DELETED_ENTITY"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteFilesetResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteFilesetResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_FILESET_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteFilesetResponse::NotAuthorized
- {
- body,
- www_authenticate
- }
- => {
- let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteFilesetResponse::NotAuthorized {
+ body,
+ www_authenticate,
+ } => {
+ if let Some(www_authenticate) = www_authenticate {
+ let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
Ok(val) => val,
Err(e) => {
- return future::ok(Response::builder()
+ return Ok(Response::builder()
.status(StatusCode::INTERNAL_SERVER_ERROR)
.body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
.expect("Unable to create Internal Server Error for invalid response header"))
}
};
- *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
- response.headers_mut().insert(
- HeaderName::from_static("www_authenticate"),
- www_authenticate
- );
- response.headers_mut().insert(
+ response.headers_mut().insert(
+ HeaderName::from_static("www_authenticate"),
+ www_authenticate,
+ );
+ }
+ *response.status_mut() = StatusCode::from_u16(401)
+ .expect("Unable to turn 401 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_FILESET_NOT_AUTHORIZED"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteFilesetResponse::Forbidden
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(403).expect("Unable to turn 403 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteFilesetResponse::Forbidden(body) => {
+ *response.status_mut() = StatusCode::from_u16(403)
+ .expect("Unable to turn 403 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_FILESET_FORBIDDEN"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteFilesetResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteFilesetResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_FILESET_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteFilesetResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteFilesetResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_FILESET_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // DeleteFilesetEdit - DELETE /editgroup/{editgroup_id}/fileset/edit/{edit_id}
- &hyper::Method::DELETE
- if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_FILESET_EDIT_EDIT_ID) =>
- {
+ Ok(response)
+ }
+
+ // DeleteFilesetEdit - DELETE /editgroup/{editgroup_id}/fileset/edit/{edit_id}
+ &hyper::Method::DELETE
+ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_FILESET_EDIT_EDIT_ID) =>
{
- let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
- &Some(ref authorization) => authorization,
- &None => {
- return Box::new(future::ok(
- Response::builder()
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>)
+ .get()
+ {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Ok(Response::builder()
.status(StatusCode::FORBIDDEN)
.body(Body::from("Unauthenticated"))
- .expect("Unable to create Authentication Forbidden response"),
- ))
- }
- };
- }
+ .expect("Unable to create Authentication Forbidden response"))
+ }
+ };
+ }
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_EDITGROUP_EDITGROUP_ID_FILESET_EDIT_EDIT_ID
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID_FILESET_EDIT_EDIT_ID in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID_FILESET_EDIT_EDIT_ID.as_str())
);
- let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
Ok(param_editgroup_id) => param_editgroup_id,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- let param_edit_id = match percent_encoding::percent_decode(path_params["edit_id"].as_bytes()).decode_utf8() {
+ let param_edit_id = match percent_encoding::percent_decode(path_params["edit_id"].as_bytes()).decode_utf8() {
Ok(param_edit_id) => match param_edit_id.parse::<String>() {
Ok(param_edit_id) => param_edit_id,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter edit_id: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["edit_id"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- Box::new({
- {
- {
- Box::new(
- api_impl.delete_fileset_edit(
- param_editgroup_id,
- param_edit_id,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ let result = api_impl
+ .delete_fileset_edit(param_editgroup_id, param_edit_id, &context)
+ .await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
- match result {
- Ok(rsp) => match rsp {
- DeleteFilesetEditResponse::DeletedEdit
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ match result {
+ Ok(rsp) => match rsp {
+ DeleteFilesetEditResponse::DeletedEdit(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_FILESET_EDIT_DELETED_EDIT"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteFilesetEditResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteFilesetEditResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_FILESET_EDIT_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteFilesetEditResponse::NotAuthorized
- {
- body,
- www_authenticate
- }
- => {
- let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteFilesetEditResponse::NotAuthorized {
+ body,
+ www_authenticate,
+ } => {
+ if let Some(www_authenticate) = www_authenticate {
+ let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
Ok(val) => val,
Err(e) => {
- return future::ok(Response::builder()
+ return Ok(Response::builder()
.status(StatusCode::INTERNAL_SERVER_ERROR)
.body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
.expect("Unable to create Internal Server Error for invalid response header"))
}
};
- *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
- response.headers_mut().insert(
- HeaderName::from_static("www_authenticate"),
- www_authenticate
- );
- response.headers_mut().insert(
+ response.headers_mut().insert(
+ HeaderName::from_static("www_authenticate"),
+ www_authenticate,
+ );
+ }
+ *response.status_mut() = StatusCode::from_u16(401)
+ .expect("Unable to turn 401 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_FILESET_EDIT_NOT_AUTHORIZED"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteFilesetEditResponse::Forbidden
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(403).expect("Unable to turn 403 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteFilesetEditResponse::Forbidden(body) => {
+ *response.status_mut() = StatusCode::from_u16(403)
+ .expect("Unable to turn 403 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_FILESET_EDIT_FORBIDDEN"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteFilesetEditResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteFilesetEditResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_FILESET_EDIT_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteFilesetEditResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteFilesetEditResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_FILESET_EDIT_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // DeleteRelease - DELETE /editgroup/{editgroup_id}/release/{ident}
- &hyper::Method::DELETE
- if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_RELEASE_IDENT) =>
- {
+ Ok(response)
+ }
+
+ // DeleteRelease - DELETE /editgroup/{editgroup_id}/release/{ident}
+ &hyper::Method::DELETE
+ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_RELEASE_IDENT) =>
{
- let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
- &Some(ref authorization) => authorization,
- &None => {
- return Box::new(future::ok(
- Response::builder()
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>)
+ .get()
+ {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Ok(Response::builder()
.status(StatusCode::FORBIDDEN)
.body(Body::from("Unauthenticated"))
- .expect("Unable to create Authentication Forbidden response"),
- ))
- }
- };
- }
+ .expect("Unable to create Authentication Forbidden response"))
+ }
+ };
+ }
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_EDITGROUP_EDITGROUP_ID_RELEASE_IDENT
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID_RELEASE_IDENT in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID_RELEASE_IDENT.as_str())
);
- let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
Ok(param_editgroup_id) => param_editgroup_id,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
Ok(param_ident) => match param_ident.parse::<String>() {
Ok(param_ident) => param_ident,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- Box::new({
- {
- {
- Box::new(
- api_impl.delete_release(
- param_editgroup_id,
- param_ident,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ let result = api_impl
+ .delete_release(param_editgroup_id, param_ident, &context)
+ .await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
- match result {
- Ok(rsp) => match rsp {
- DeleteReleaseResponse::DeletedEntity
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ match result {
+ Ok(rsp) => match rsp {
+ DeleteReleaseResponse::DeletedEntity(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_RELEASE_DELETED_ENTITY"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteReleaseResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteReleaseResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_RELEASE_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteReleaseResponse::NotAuthorized
- {
- body,
- www_authenticate
- }
- => {
- let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteReleaseResponse::NotAuthorized {
+ body,
+ www_authenticate,
+ } => {
+ if let Some(www_authenticate) = www_authenticate {
+ let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
Ok(val) => val,
Err(e) => {
- return future::ok(Response::builder()
+ return Ok(Response::builder()
.status(StatusCode::INTERNAL_SERVER_ERROR)
.body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
.expect("Unable to create Internal Server Error for invalid response header"))
}
};
- *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
- response.headers_mut().insert(
- HeaderName::from_static("www_authenticate"),
- www_authenticate
- );
- response.headers_mut().insert(
+ response.headers_mut().insert(
+ HeaderName::from_static("www_authenticate"),
+ www_authenticate,
+ );
+ }
+ *response.status_mut() = StatusCode::from_u16(401)
+ .expect("Unable to turn 401 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_RELEASE_NOT_AUTHORIZED"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteReleaseResponse::Forbidden
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(403).expect("Unable to turn 403 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteReleaseResponse::Forbidden(body) => {
+ *response.status_mut() = StatusCode::from_u16(403)
+ .expect("Unable to turn 403 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_RELEASE_FORBIDDEN"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteReleaseResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteReleaseResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_RELEASE_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteReleaseResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteReleaseResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_RELEASE_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // DeleteReleaseEdit - DELETE /editgroup/{editgroup_id}/release/edit/{edit_id}
- &hyper::Method::DELETE
- if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_RELEASE_EDIT_EDIT_ID) =>
- {
+ Ok(response)
+ }
+
+ // DeleteReleaseEdit - DELETE /editgroup/{editgroup_id}/release/edit/{edit_id}
+ &hyper::Method::DELETE
+ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_RELEASE_EDIT_EDIT_ID) =>
{
- let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
- &Some(ref authorization) => authorization,
- &None => {
- return Box::new(future::ok(
- Response::builder()
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>)
+ .get()
+ {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Ok(Response::builder()
.status(StatusCode::FORBIDDEN)
.body(Body::from("Unauthenticated"))
- .expect("Unable to create Authentication Forbidden response"),
- ))
- }
- };
- }
+ .expect("Unable to create Authentication Forbidden response"))
+ }
+ };
+ }
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_EDITGROUP_EDITGROUP_ID_RELEASE_EDIT_EDIT_ID
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID_RELEASE_EDIT_EDIT_ID in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID_RELEASE_EDIT_EDIT_ID.as_str())
);
- let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
Ok(param_editgroup_id) => param_editgroup_id,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- let param_edit_id = match percent_encoding::percent_decode(path_params["edit_id"].as_bytes()).decode_utf8() {
+ let param_edit_id = match percent_encoding::percent_decode(path_params["edit_id"].as_bytes()).decode_utf8() {
Ok(param_edit_id) => match param_edit_id.parse::<String>() {
Ok(param_edit_id) => param_edit_id,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter edit_id: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["edit_id"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- Box::new({
- {
- {
- Box::new(
- api_impl.delete_release_edit(
- param_editgroup_id,
- param_edit_id,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ let result = api_impl
+ .delete_release_edit(param_editgroup_id, param_edit_id, &context)
+ .await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
- match result {
- Ok(rsp) => match rsp {
- DeleteReleaseEditResponse::DeletedEdit
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ match result {
+ Ok(rsp) => match rsp {
+ DeleteReleaseEditResponse::DeletedEdit(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_RELEASE_EDIT_DELETED_EDIT"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteReleaseEditResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteReleaseEditResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_RELEASE_EDIT_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteReleaseEditResponse::NotAuthorized
- {
- body,
- www_authenticate
- }
- => {
- let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteReleaseEditResponse::NotAuthorized {
+ body,
+ www_authenticate,
+ } => {
+ if let Some(www_authenticate) = www_authenticate {
+ let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
Ok(val) => val,
Err(e) => {
- return future::ok(Response::builder()
+ return Ok(Response::builder()
.status(StatusCode::INTERNAL_SERVER_ERROR)
.body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
.expect("Unable to create Internal Server Error for invalid response header"))
}
};
- *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
- response.headers_mut().insert(
- HeaderName::from_static("www_authenticate"),
- www_authenticate
- );
- response.headers_mut().insert(
+ response.headers_mut().insert(
+ HeaderName::from_static("www_authenticate"),
+ www_authenticate,
+ );
+ }
+ *response.status_mut() = StatusCode::from_u16(401)
+ .expect("Unable to turn 401 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_RELEASE_EDIT_NOT_AUTHORIZED"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteReleaseEditResponse::Forbidden
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(403).expect("Unable to turn 403 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteReleaseEditResponse::Forbidden(body) => {
+ *response.status_mut() = StatusCode::from_u16(403)
+ .expect("Unable to turn 403 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_RELEASE_EDIT_FORBIDDEN"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteReleaseEditResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteReleaseEditResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_RELEASE_EDIT_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteReleaseEditResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteReleaseEditResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_RELEASE_EDIT_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // DeleteWebcapture - DELETE /editgroup/{editgroup_id}/webcapture/{ident}
- &hyper::Method::DELETE
- if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_WEBCAPTURE_IDENT) =>
- {
+ Ok(response)
+ }
+
+ // DeleteWebcapture - DELETE /editgroup/{editgroup_id}/webcapture/{ident}
+ &hyper::Method::DELETE
+ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_WEBCAPTURE_IDENT) =>
{
- let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
- &Some(ref authorization) => authorization,
- &None => {
- return Box::new(future::ok(
- Response::builder()
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>)
+ .get()
+ {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Ok(Response::builder()
.status(StatusCode::FORBIDDEN)
.body(Body::from("Unauthenticated"))
- .expect("Unable to create Authentication Forbidden response"),
- ))
- }
- };
- }
+ .expect("Unable to create Authentication Forbidden response"))
+ }
+ };
+ }
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_EDITGROUP_EDITGROUP_ID_WEBCAPTURE_IDENT
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID_WEBCAPTURE_IDENT in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID_WEBCAPTURE_IDENT.as_str())
);
- let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
Ok(param_editgroup_id) => param_editgroup_id,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
Ok(param_ident) => match param_ident.parse::<String>() {
Ok(param_ident) => param_ident,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- Box::new({
- {
- {
- Box::new(
- api_impl.delete_webcapture(
- param_editgroup_id,
- param_ident,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ let result = api_impl
+ .delete_webcapture(param_editgroup_id, param_ident, &context)
+ .await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
- match result {
- Ok(rsp) => match rsp {
- DeleteWebcaptureResponse::DeletedEntity
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ match result {
+ Ok(rsp) => match rsp {
+ DeleteWebcaptureResponse::DeletedEntity(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_WEBCAPTURE_DELETED_ENTITY"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteWebcaptureResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteWebcaptureResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_WEBCAPTURE_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteWebcaptureResponse::NotAuthorized
- {
- body,
- www_authenticate
- }
- => {
- let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteWebcaptureResponse::NotAuthorized {
+ body,
+ www_authenticate,
+ } => {
+ if let Some(www_authenticate) = www_authenticate {
+ let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
Ok(val) => val,
Err(e) => {
- return future::ok(Response::builder()
+ return Ok(Response::builder()
.status(StatusCode::INTERNAL_SERVER_ERROR)
.body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
.expect("Unable to create Internal Server Error for invalid response header"))
}
};
- *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
- response.headers_mut().insert(
- HeaderName::from_static("www_authenticate"),
- www_authenticate
- );
- response.headers_mut().insert(
+ response.headers_mut().insert(
+ HeaderName::from_static("www_authenticate"),
+ www_authenticate,
+ );
+ }
+ *response.status_mut() = StatusCode::from_u16(401)
+ .expect("Unable to turn 401 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_WEBCAPTURE_NOT_AUTHORIZED"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteWebcaptureResponse::Forbidden
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(403).expect("Unable to turn 403 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteWebcaptureResponse::Forbidden(body) => {
+ *response.status_mut() = StatusCode::from_u16(403)
+ .expect("Unable to turn 403 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_WEBCAPTURE_FORBIDDEN"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteWebcaptureResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteWebcaptureResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_WEBCAPTURE_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteWebcaptureResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteWebcaptureResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_WEBCAPTURE_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // DeleteWebcaptureEdit - DELETE /editgroup/{editgroup_id}/webcapture/edit/{edit_id}
- &hyper::Method::DELETE
- if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_WEBCAPTURE_EDIT_EDIT_ID) =>
- {
+ Ok(response)
+ }
+
+ // DeleteWebcaptureEdit - DELETE /editgroup/{editgroup_id}/webcapture/edit/{edit_id}
+ &hyper::Method::DELETE
+ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_WEBCAPTURE_EDIT_EDIT_ID) =>
{
- let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
- &Some(ref authorization) => authorization,
- &None => {
- return Box::new(future::ok(
- Response::builder()
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>)
+ .get()
+ {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Ok(Response::builder()
.status(StatusCode::FORBIDDEN)
.body(Body::from("Unauthenticated"))
- .expect("Unable to create Authentication Forbidden response"),
- ))
- }
- };
- }
+ .expect("Unable to create Authentication Forbidden response"))
+ }
+ };
+ }
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_EDITGROUP_EDITGROUP_ID_WEBCAPTURE_EDIT_EDIT_ID
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID_WEBCAPTURE_EDIT_EDIT_ID in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID_WEBCAPTURE_EDIT_EDIT_ID.as_str())
);
- let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
Ok(param_editgroup_id) => param_editgroup_id,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- let param_edit_id = match percent_encoding::percent_decode(path_params["edit_id"].as_bytes()).decode_utf8() {
+ let param_edit_id = match percent_encoding::percent_decode(path_params["edit_id"].as_bytes()).decode_utf8() {
Ok(param_edit_id) => match param_edit_id.parse::<String>() {
Ok(param_edit_id) => param_edit_id,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter edit_id: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["edit_id"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- Box::new({
- {
- {
- Box::new(
- api_impl.delete_webcapture_edit(
- param_editgroup_id,
- param_edit_id,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ let result = api_impl
+ .delete_webcapture_edit(param_editgroup_id, param_edit_id, &context)
+ .await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
- match result {
- Ok(rsp) => match rsp {
- DeleteWebcaptureEditResponse::DeletedEdit
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ match result {
+ Ok(rsp) => match rsp {
+ DeleteWebcaptureEditResponse::DeletedEdit(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_WEBCAPTURE_EDIT_DELETED_EDIT"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteWebcaptureEditResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteWebcaptureEditResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_WEBCAPTURE_EDIT_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteWebcaptureEditResponse::NotAuthorized
- {
- body,
- www_authenticate
- }
- => {
- let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteWebcaptureEditResponse::NotAuthorized {
+ body,
+ www_authenticate,
+ } => {
+ if let Some(www_authenticate) = www_authenticate {
+ let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
Ok(val) => val,
Err(e) => {
- return future::ok(Response::builder()
+ return Ok(Response::builder()
.status(StatusCode::INTERNAL_SERVER_ERROR)
.body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
.expect("Unable to create Internal Server Error for invalid response header"))
}
};
- *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
- response.headers_mut().insert(
- HeaderName::from_static("www_authenticate"),
- www_authenticate
- );
- response.headers_mut().insert(
+ response.headers_mut().insert(
+ HeaderName::from_static("www_authenticate"),
+ www_authenticate,
+ );
+ }
+ *response.status_mut() = StatusCode::from_u16(401)
+ .expect("Unable to turn 401 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_WEBCAPTURE_EDIT_NOT_AUTHORIZED"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteWebcaptureEditResponse::Forbidden
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(403).expect("Unable to turn 403 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteWebcaptureEditResponse::Forbidden(body) => {
+ *response.status_mut() = StatusCode::from_u16(403)
+ .expect("Unable to turn 403 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_WEBCAPTURE_EDIT_FORBIDDEN"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteWebcaptureEditResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteWebcaptureEditResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_WEBCAPTURE_EDIT_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteWebcaptureEditResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteWebcaptureEditResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_WEBCAPTURE_EDIT_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // DeleteWork - DELETE /editgroup/{editgroup_id}/work/{ident}
- &hyper::Method::DELETE if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_WORK_IDENT) => {
+ Ok(response)
+ }
+
+ // DeleteWork - DELETE /editgroup/{editgroup_id}/work/{ident}
+ &hyper::Method::DELETE
+ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_WORK_IDENT) =>
{
- let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
- &Some(ref authorization) => authorization,
- &None => {
- return Box::new(future::ok(
- Response::builder()
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>)
+ .get()
+ {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Ok(Response::builder()
.status(StatusCode::FORBIDDEN)
.body(Body::from("Unauthenticated"))
- .expect("Unable to create Authentication Forbidden response"),
- ))
- }
- };
- }
+ .expect("Unable to create Authentication Forbidden response"))
+ }
+ };
+ }
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_EDITGROUP_EDITGROUP_ID_WORK_IDENT
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID_WORK_IDENT in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID_WORK_IDENT.as_str())
);
- let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
Ok(param_editgroup_id) => param_editgroup_id,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
Ok(param_ident) => match param_ident.parse::<String>() {
Ok(param_ident) => param_ident,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- Box::new({
- {
- {
- Box::new(
- api_impl.delete_work(
- param_editgroup_id,
- param_ident,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ let result = api_impl
+ .delete_work(param_editgroup_id, param_ident, &context)
+ .await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
- match result {
- Ok(rsp) => match rsp {
- DeleteWorkResponse::DeletedEntity
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ match result {
+ Ok(rsp) => match rsp {
+ DeleteWorkResponse::DeletedEntity(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_WORK_DELETED_ENTITY"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteWorkResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteWorkResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_WORK_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteWorkResponse::NotAuthorized
- {
- body,
- www_authenticate
- }
- => {
- let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteWorkResponse::NotAuthorized {
+ body,
+ www_authenticate,
+ } => {
+ if let Some(www_authenticate) = www_authenticate {
+ let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
Ok(val) => val,
Err(e) => {
- return future::ok(Response::builder()
+ return Ok(Response::builder()
.status(StatusCode::INTERNAL_SERVER_ERROR)
.body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
.expect("Unable to create Internal Server Error for invalid response header"))
}
};
- *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
- response.headers_mut().insert(
- HeaderName::from_static("www_authenticate"),
- www_authenticate
- );
- response.headers_mut().insert(
+ response.headers_mut().insert(
+ HeaderName::from_static("www_authenticate"),
+ www_authenticate,
+ );
+ }
+ *response.status_mut() = StatusCode::from_u16(401)
+ .expect("Unable to turn 401 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_WORK_NOT_AUTHORIZED"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteWorkResponse::Forbidden
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(403).expect("Unable to turn 403 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteWorkResponse::Forbidden(body) => {
+ *response.status_mut() = StatusCode::from_u16(403)
+ .expect("Unable to turn 403 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_WORK_FORBIDDEN"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteWorkResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteWorkResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_WORK_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteWorkResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteWorkResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_WORK_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // DeleteWorkEdit - DELETE /editgroup/{editgroup_id}/work/edit/{edit_id}
- &hyper::Method::DELETE
- if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_WORK_EDIT_EDIT_ID) =>
- {
+ Ok(response)
+ }
+
+ // DeleteWorkEdit - DELETE /editgroup/{editgroup_id}/work/edit/{edit_id}
+ &hyper::Method::DELETE
+ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_WORK_EDIT_EDIT_ID) =>
{
- let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
- &Some(ref authorization) => authorization,
- &None => {
- return Box::new(future::ok(
- Response::builder()
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>)
+ .get()
+ {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Ok(Response::builder()
.status(StatusCode::FORBIDDEN)
.body(Body::from("Unauthenticated"))
- .expect("Unable to create Authentication Forbidden response"),
- ))
- }
- };
- }
+ .expect("Unable to create Authentication Forbidden response"))
+ }
+ };
+ }
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_EDITGROUP_EDITGROUP_ID_WORK_EDIT_EDIT_ID
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID_WORK_EDIT_EDIT_ID in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID_WORK_EDIT_EDIT_ID.as_str())
);
- let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
Ok(param_editgroup_id) => param_editgroup_id,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- let param_edit_id = match percent_encoding::percent_decode(path_params["edit_id"].as_bytes()).decode_utf8() {
+ let param_edit_id = match percent_encoding::percent_decode(path_params["edit_id"].as_bytes()).decode_utf8() {
Ok(param_edit_id) => match param_edit_id.parse::<String>() {
Ok(param_edit_id) => param_edit_id,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter edit_id: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["edit_id"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- Box::new({
- {
- {
- Box::new(
- api_impl.delete_work_edit(
- param_editgroup_id,
- param_edit_id,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ let result = api_impl
+ .delete_work_edit(param_editgroup_id, param_edit_id, &context)
+ .await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
- match result {
- Ok(rsp) => match rsp {
- DeleteWorkEditResponse::DeletedEdit
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ match result {
+ Ok(rsp) => match rsp {
+ DeleteWorkEditResponse::DeletedEdit(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_WORK_EDIT_DELETED_EDIT"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteWorkEditResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteWorkEditResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_WORK_EDIT_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteWorkEditResponse::NotAuthorized
- {
- body,
- www_authenticate
- }
- => {
- let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteWorkEditResponse::NotAuthorized {
+ body,
+ www_authenticate,
+ } => {
+ if let Some(www_authenticate) = www_authenticate {
+ let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
Ok(val) => val,
Err(e) => {
- return future::ok(Response::builder()
+ return Ok(Response::builder()
.status(StatusCode::INTERNAL_SERVER_ERROR)
.body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
.expect("Unable to create Internal Server Error for invalid response header"))
}
};
- *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
- response.headers_mut().insert(
- HeaderName::from_static("www_authenticate"),
- www_authenticate
- );
- response.headers_mut().insert(
+ response.headers_mut().insert(
+ HeaderName::from_static("www_authenticate"),
+ www_authenticate,
+ );
+ }
+ *response.status_mut() = StatusCode::from_u16(401)
+ .expect("Unable to turn 401 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_WORK_EDIT_NOT_AUTHORIZED"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteWorkEditResponse::Forbidden
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(403).expect("Unable to turn 403 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteWorkEditResponse::Forbidden(body) => {
+ *response.status_mut() = StatusCode::from_u16(403)
+ .expect("Unable to turn 403 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_WORK_EDIT_FORBIDDEN"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteWorkEditResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteWorkEditResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_WORK_EDIT_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- DeleteWorkEditResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ DeleteWorkEditResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for DELETE_WORK_EDIT_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // GetChangelog - GET /changelog
- &hyper::Method::GET if path.matched(paths::ID_CHANGELOG) => {
- // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
- let query_params =
- form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
- .collect::<Vec<_>>();
- let param_limit = query_params
- .iter()
- .filter(|e| e.0 == "limit")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_limit = param_limit.and_then(|param_limit| param_limit.parse().ok());
-
- Box::new({
- {
- {
- Box::new(
- api_impl.get_changelog(
- param_limit,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ Ok(response)
+ }
- match result {
- Ok(rsp) => match rsp {
- GetChangelogResponse::Success
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ // GetChangelog - GET /changelog
+ &hyper::Method::GET if path.matched(paths::ID_CHANGELOG) => {
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_limit = query_params
+ .iter()
+ .filter(|e| e.0 == "limit")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_limit = match param_limit {
+ Some(param_limit) => {
+ let param_limit = <i64 as std::str::FromStr>::from_str(&param_limit);
+ match param_limit {
+ Ok(param_limit) => Some(param_limit),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter limit - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter limit")),
+ }
+ }
+ None => None,
+ };
+
+ let result = api_impl.get_changelog(param_limit, &context).await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetChangelogResponse::Success(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_CHANGELOG_SUCCESS"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetChangelogResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetChangelogResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_CHANGELOG_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetChangelogResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetChangelogResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_CHANGELOG_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // GetChangelogEntry - GET /changelog/{index}
- &hyper::Method::GET if path.matched(paths::ID_CHANGELOG_INDEX) => {
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ Ok(response)
+ }
+
+ // GetChangelogEntry - GET /changelog/{index}
+ &hyper::Method::GET if path.matched(paths::ID_CHANGELOG_INDEX) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_CHANGELOG_INDEX
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE CHANGELOG_INDEX in set but failed match against \"{}\"", path, paths::REGEX_CHANGELOG_INDEX.as_str())
);
- let param_index = match percent_encoding::percent_decode(path_params["index"].as_bytes()).decode_utf8() {
+ let param_index = match percent_encoding::percent_decode(path_params["index"].as_bytes()).decode_utf8() {
Ok(param_index) => match param_index.parse::<i64>() {
Ok(param_index) => param_index,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter index: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["index"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- Box::new({
- {
- {
- Box::new(
- api_impl.get_changelog_entry(
- param_index,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ let result = api_impl.get_changelog_entry(param_index, &context).await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
- match result {
- Ok(rsp) => match rsp {
- GetChangelogEntryResponse::FoundChangelogEntry
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ match result {
+ Ok(rsp) => match rsp {
+ GetChangelogEntryResponse::FoundChangelogEntry(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_CHANGELOG_ENTRY_FOUND_CHANGELOG_ENTRY"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetChangelogEntryResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetChangelogEntryResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_CHANGELOG_ENTRY_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetChangelogEntryResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetChangelogEntryResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_CHANGELOG_ENTRY_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetChangelogEntryResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetChangelogEntryResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_CHANGELOG_ENTRY_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // GetContainer - GET /container/{ident}
- &hyper::Method::GET if path.matched(paths::ID_CONTAINER_IDENT) => {
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ Ok(response)
+ }
+
+ // GetContainer - GET /container/{ident}
+ &hyper::Method::GET if path.matched(paths::ID_CONTAINER_IDENT) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_CONTAINER_IDENT
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE CONTAINER_IDENT in set but failed match against \"{}\"", path, paths::REGEX_CONTAINER_IDENT.as_str())
);
- let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
Ok(param_ident) => match param_ident.parse::<String>() {
Ok(param_ident) => param_ident,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
- let query_params =
- form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
- .collect::<Vec<_>>();
- let param_expand = query_params
- .iter()
- .filter(|e| e.0 == "expand")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_expand = param_expand.and_then(|param_expand| param_expand.parse().ok());
- let param_hide = query_params
- .iter()
- .filter(|e| e.0 == "hide")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_hide = param_hide.and_then(|param_hide| param_hide.parse().ok());
-
- Box::new({
- {
- {
- Box::new(
- api_impl.get_container(
- param_ident,
- param_expand,
- param_hide,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_expand = query_params
+ .iter()
+ .filter(|e| e.0 == "expand")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_expand = match param_expand {
+ Some(param_expand) => {
+ let param_expand =
+ <String as std::str::FromStr>::from_str(&param_expand);
+ match param_expand {
+ Ok(param_expand) => Some(param_expand),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter expand - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter expand")),
+ }
+ }
+ None => None,
+ };
+ let param_hide = query_params
+ .iter()
+ .filter(|e| e.0 == "hide")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_hide = match param_hide {
+ Some(param_hide) => {
+ let param_hide = <String as std::str::FromStr>::from_str(&param_hide);
+ match param_hide {
+ Ok(param_hide) => Some(param_hide),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter hide - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter hide")),
+ }
+ }
+ None => None,
+ };
- match result {
- Ok(rsp) => match rsp {
- GetContainerResponse::FoundEntity
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ let result = api_impl
+ .get_container(param_ident, param_expand, param_hide, &context)
+ .await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetContainerResponse::FoundEntity(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_CONTAINER_FOUND_ENTITY"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetContainerResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetContainerResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_CONTAINER_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetContainerResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetContainerResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_CONTAINER_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetContainerResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetContainerResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_CONTAINER_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // GetContainerEdit - GET /container/edit/{edit_id}
- &hyper::Method::GET if path.matched(paths::ID_CONTAINER_EDIT_EDIT_ID) => {
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ Ok(response)
+ }
+
+ // GetContainerEdit - GET /container/edit/{edit_id}
+ &hyper::Method::GET if path.matched(paths::ID_CONTAINER_EDIT_EDIT_ID) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_CONTAINER_EDIT_EDIT_ID
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE CONTAINER_EDIT_EDIT_ID in set but failed match against \"{}\"", path, paths::REGEX_CONTAINER_EDIT_EDIT_ID.as_str())
);
- let param_edit_id = match percent_encoding::percent_decode(path_params["edit_id"].as_bytes()).decode_utf8() {
+ let param_edit_id = match percent_encoding::percent_decode(path_params["edit_id"].as_bytes()).decode_utf8() {
Ok(param_edit_id) => match param_edit_id.parse::<String>() {
Ok(param_edit_id) => param_edit_id,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter edit_id: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["edit_id"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- Box::new({
- {
- {
- Box::new(
- api_impl.get_container_edit(
- param_edit_id,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ let result = api_impl.get_container_edit(param_edit_id, &context).await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
- match result {
- Ok(rsp) => match rsp {
- GetContainerEditResponse::FoundEdit
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ match result {
+ Ok(rsp) => match rsp {
+ GetContainerEditResponse::FoundEdit(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_CONTAINER_EDIT_FOUND_EDIT"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetContainerEditResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetContainerEditResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_CONTAINER_EDIT_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetContainerEditResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetContainerEditResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_CONTAINER_EDIT_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetContainerEditResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetContainerEditResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_CONTAINER_EDIT_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // GetContainerHistory - GET /container/{ident}/history
- &hyper::Method::GET if path.matched(paths::ID_CONTAINER_IDENT_HISTORY) => {
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ Ok(response)
+ }
+
+ // GetContainerHistory - GET /container/{ident}/history
+ &hyper::Method::GET if path.matched(paths::ID_CONTAINER_IDENT_HISTORY) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_CONTAINER_IDENT_HISTORY
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE CONTAINER_IDENT_HISTORY in set but failed match against \"{}\"", path, paths::REGEX_CONTAINER_IDENT_HISTORY.as_str())
);
- let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
Ok(param_ident) => match param_ident.parse::<String>() {
Ok(param_ident) => param_ident,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
- let query_params =
- form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
- .collect::<Vec<_>>();
- let param_limit = query_params
- .iter()
- .filter(|e| e.0 == "limit")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_limit = param_limit.and_then(|param_limit| param_limit.parse().ok());
-
- Box::new({
- {
- {
- Box::new(
- api_impl.get_container_history(
- param_ident,
- param_limit,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_limit = query_params
+ .iter()
+ .filter(|e| e.0 == "limit")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_limit = match param_limit {
+ Some(param_limit) => {
+ let param_limit = <i64 as std::str::FromStr>::from_str(&param_limit);
+ match param_limit {
+ Ok(param_limit) => Some(param_limit),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter limit - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter limit")),
+ }
+ }
+ None => None,
+ };
- match result {
- Ok(rsp) => match rsp {
- GetContainerHistoryResponse::FoundEntityHistory
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ let result = api_impl
+ .get_container_history(param_ident, param_limit, &context)
+ .await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetContainerHistoryResponse::FoundEntityHistory(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_CONTAINER_HISTORY_FOUND_ENTITY_HISTORY"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetContainerHistoryResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetContainerHistoryResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_CONTAINER_HISTORY_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetContainerHistoryResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetContainerHistoryResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_CONTAINER_HISTORY_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetContainerHistoryResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetContainerHistoryResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_CONTAINER_HISTORY_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // GetContainerRedirects - GET /container/{ident}/redirects
- &hyper::Method::GET if path.matched(paths::ID_CONTAINER_IDENT_REDIRECTS) => {
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ Ok(response)
+ }
+
+ // GetContainerRedirects - GET /container/{ident}/redirects
+ &hyper::Method::GET if path.matched(paths::ID_CONTAINER_IDENT_REDIRECTS) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_CONTAINER_IDENT_REDIRECTS
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE CONTAINER_IDENT_REDIRECTS in set but failed match against \"{}\"", path, paths::REGEX_CONTAINER_IDENT_REDIRECTS.as_str())
);
- let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
Ok(param_ident) => match param_ident.parse::<String>() {
Ok(param_ident) => param_ident,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- Box::new({
- {
- {
- Box::new(
- api_impl.get_container_redirects(
- param_ident,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ let result = api_impl
+ .get_container_redirects(param_ident, &context)
+ .await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
- match result {
- Ok(rsp) => match rsp {
- GetContainerRedirectsResponse::FoundEntityRedirects
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ match result {
+ Ok(rsp) => match rsp {
+ GetContainerRedirectsResponse::FoundEntityRedirects(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_CONTAINER_REDIRECTS_FOUND_ENTITY_REDIRECTS"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetContainerRedirectsResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetContainerRedirectsResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_CONTAINER_REDIRECTS_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetContainerRedirectsResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetContainerRedirectsResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_CONTAINER_REDIRECTS_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetContainerRedirectsResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetContainerRedirectsResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_CONTAINER_REDIRECTS_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // GetContainerRevision - GET /container/rev/{rev_id}
- &hyper::Method::GET if path.matched(paths::ID_CONTAINER_REV_REV_ID) => {
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ Ok(response)
+ }
+
+ // GetContainerRevision - GET /container/rev/{rev_id}
+ &hyper::Method::GET if path.matched(paths::ID_CONTAINER_REV_REV_ID) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_CONTAINER_REV_REV_ID
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE CONTAINER_REV_REV_ID in set but failed match against \"{}\"", path, paths::REGEX_CONTAINER_REV_REV_ID.as_str())
);
- let param_rev_id = match percent_encoding::percent_decode(path_params["rev_id"].as_bytes()).decode_utf8() {
+ let param_rev_id = match percent_encoding::percent_decode(path_params["rev_id"].as_bytes()).decode_utf8() {
Ok(param_rev_id) => match param_rev_id.parse::<String>() {
Ok(param_rev_id) => param_rev_id,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter rev_id: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["rev_id"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
- let query_params =
- form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
- .collect::<Vec<_>>();
- let param_expand = query_params
- .iter()
- .filter(|e| e.0 == "expand")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_expand = param_expand.and_then(|param_expand| param_expand.parse().ok());
- let param_hide = query_params
- .iter()
- .filter(|e| e.0 == "hide")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_hide = param_hide.and_then(|param_hide| param_hide.parse().ok());
-
- Box::new({
- {
- {
- Box::new(
- api_impl.get_container_revision(
- param_rev_id,
- param_expand,
- param_hide,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_expand = query_params
+ .iter()
+ .filter(|e| e.0 == "expand")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_expand = match param_expand {
+ Some(param_expand) => {
+ let param_expand =
+ <String as std::str::FromStr>::from_str(&param_expand);
+ match param_expand {
+ Ok(param_expand) => Some(param_expand),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter expand - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter expand")),
+ }
+ }
+ None => None,
+ };
+ let param_hide = query_params
+ .iter()
+ .filter(|e| e.0 == "hide")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_hide = match param_hide {
+ Some(param_hide) => {
+ let param_hide = <String as std::str::FromStr>::from_str(&param_hide);
+ match param_hide {
+ Ok(param_hide) => Some(param_hide),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter hide - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter hide")),
+ }
+ }
+ None => None,
+ };
- match result {
- Ok(rsp) => match rsp {
- GetContainerRevisionResponse::FoundEntityRevision
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ let result = api_impl
+ .get_container_revision(param_rev_id, param_expand, param_hide, &context)
+ .await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetContainerRevisionResponse::FoundEntityRevision(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_CONTAINER_REVISION_FOUND_ENTITY_REVISION"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetContainerRevisionResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetContainerRevisionResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_CONTAINER_REVISION_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetContainerRevisionResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetContainerRevisionResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_CONTAINER_REVISION_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetContainerRevisionResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetContainerRevisionResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_CONTAINER_REVISION_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // GetCreator - GET /creator/{ident}
- &hyper::Method::GET if path.matched(paths::ID_CREATOR_IDENT) => {
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ Ok(response)
+ }
+
+ // GetCreator - GET /creator/{ident}
+ &hyper::Method::GET if path.matched(paths::ID_CREATOR_IDENT) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_CREATOR_IDENT
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE CREATOR_IDENT in set but failed match against \"{}\"", path, paths::REGEX_CREATOR_IDENT.as_str())
);
- let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
Ok(param_ident) => match param_ident.parse::<String>() {
Ok(param_ident) => param_ident,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
- let query_params =
- form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
- .collect::<Vec<_>>();
- let param_expand = query_params
- .iter()
- .filter(|e| e.0 == "expand")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_expand = param_expand.and_then(|param_expand| param_expand.parse().ok());
- let param_hide = query_params
- .iter()
- .filter(|e| e.0 == "hide")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_hide = param_hide.and_then(|param_hide| param_hide.parse().ok());
-
- Box::new({
- {
- {
- Box::new(
- api_impl.get_creator(
- param_ident,
- param_expand,
- param_hide,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_expand = query_params
+ .iter()
+ .filter(|e| e.0 == "expand")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_expand = match param_expand {
+ Some(param_expand) => {
+ let param_expand =
+ <String as std::str::FromStr>::from_str(&param_expand);
+ match param_expand {
+ Ok(param_expand) => Some(param_expand),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter expand - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter expand")),
+ }
+ }
+ None => None,
+ };
+ let param_hide = query_params
+ .iter()
+ .filter(|e| e.0 == "hide")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_hide = match param_hide {
+ Some(param_hide) => {
+ let param_hide = <String as std::str::FromStr>::from_str(&param_hide);
+ match param_hide {
+ Ok(param_hide) => Some(param_hide),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter hide - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter hide")),
+ }
+ }
+ None => None,
+ };
- match result {
- Ok(rsp) => match rsp {
- GetCreatorResponse::FoundEntity
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ let result = api_impl
+ .get_creator(param_ident, param_expand, param_hide, &context)
+ .await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetCreatorResponse::FoundEntity(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_CREATOR_FOUND_ENTITY"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetCreatorResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetCreatorResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_CREATOR_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetCreatorResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetCreatorResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_CREATOR_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetCreatorResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetCreatorResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_CREATOR_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // GetCreatorEdit - GET /creator/edit/{edit_id}
- &hyper::Method::GET if path.matched(paths::ID_CREATOR_EDIT_EDIT_ID) => {
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ Ok(response)
+ }
+
+ // GetCreatorEdit - GET /creator/edit/{edit_id}
+ &hyper::Method::GET if path.matched(paths::ID_CREATOR_EDIT_EDIT_ID) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_CREATOR_EDIT_EDIT_ID
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE CREATOR_EDIT_EDIT_ID in set but failed match against \"{}\"", path, paths::REGEX_CREATOR_EDIT_EDIT_ID.as_str())
);
- let param_edit_id = match percent_encoding::percent_decode(path_params["edit_id"].as_bytes()).decode_utf8() {
+ let param_edit_id = match percent_encoding::percent_decode(path_params["edit_id"].as_bytes()).decode_utf8() {
Ok(param_edit_id) => match param_edit_id.parse::<String>() {
Ok(param_edit_id) => param_edit_id,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter edit_id: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["edit_id"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- Box::new({
- {
- {
- Box::new(
- api_impl.get_creator_edit(
- param_edit_id,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ let result = api_impl.get_creator_edit(param_edit_id, &context).await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
- match result {
- Ok(rsp) => match rsp {
- GetCreatorEditResponse::FoundEdit
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ match result {
+ Ok(rsp) => match rsp {
+ GetCreatorEditResponse::FoundEdit(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_CREATOR_EDIT_FOUND_EDIT"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetCreatorEditResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetCreatorEditResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_CREATOR_EDIT_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetCreatorEditResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetCreatorEditResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_CREATOR_EDIT_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetCreatorEditResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetCreatorEditResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_CREATOR_EDIT_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // GetCreatorHistory - GET /creator/{ident}/history
- &hyper::Method::GET if path.matched(paths::ID_CREATOR_IDENT_HISTORY) => {
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ Ok(response)
+ }
+
+ // GetCreatorHistory - GET /creator/{ident}/history
+ &hyper::Method::GET if path.matched(paths::ID_CREATOR_IDENT_HISTORY) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_CREATOR_IDENT_HISTORY
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE CREATOR_IDENT_HISTORY in set but failed match against \"{}\"", path, paths::REGEX_CREATOR_IDENT_HISTORY.as_str())
);
- let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
Ok(param_ident) => match param_ident.parse::<String>() {
Ok(param_ident) => param_ident,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
- let query_params =
- form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
- .collect::<Vec<_>>();
- let param_limit = query_params
- .iter()
- .filter(|e| e.0 == "limit")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_limit = param_limit.and_then(|param_limit| param_limit.parse().ok());
-
- Box::new({
- {
- {
- Box::new(
- api_impl.get_creator_history(
- param_ident,
- param_limit,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_limit = query_params
+ .iter()
+ .filter(|e| e.0 == "limit")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_limit = match param_limit {
+ Some(param_limit) => {
+ let param_limit = <i64 as std::str::FromStr>::from_str(&param_limit);
+ match param_limit {
+ Ok(param_limit) => Some(param_limit),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter limit - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter limit")),
+ }
+ }
+ None => None,
+ };
- match result {
- Ok(rsp) => match rsp {
- GetCreatorHistoryResponse::FoundEntityHistory
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ let result = api_impl
+ .get_creator_history(param_ident, param_limit, &context)
+ .await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetCreatorHistoryResponse::FoundEntityHistory(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_CREATOR_HISTORY_FOUND_ENTITY_HISTORY"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetCreatorHistoryResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetCreatorHistoryResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_CREATOR_HISTORY_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetCreatorHistoryResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetCreatorHistoryResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_CREATOR_HISTORY_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetCreatorHistoryResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetCreatorHistoryResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_CREATOR_HISTORY_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // GetCreatorRedirects - GET /creator/{ident}/redirects
- &hyper::Method::GET if path.matched(paths::ID_CREATOR_IDENT_REDIRECTS) => {
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ Ok(response)
+ }
+
+ // GetCreatorRedirects - GET /creator/{ident}/redirects
+ &hyper::Method::GET if path.matched(paths::ID_CREATOR_IDENT_REDIRECTS) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_CREATOR_IDENT_REDIRECTS
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE CREATOR_IDENT_REDIRECTS in set but failed match against \"{}\"", path, paths::REGEX_CREATOR_IDENT_REDIRECTS.as_str())
);
- let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
Ok(param_ident) => match param_ident.parse::<String>() {
Ok(param_ident) => param_ident,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- Box::new({
- {
- {
- Box::new(
- api_impl.get_creator_redirects(
- param_ident,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ let result = api_impl.get_creator_redirects(param_ident, &context).await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
- match result {
- Ok(rsp) => match rsp {
- GetCreatorRedirectsResponse::FoundEntityRedirects
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ match result {
+ Ok(rsp) => match rsp {
+ GetCreatorRedirectsResponse::FoundEntityRedirects(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_CREATOR_REDIRECTS_FOUND_ENTITY_REDIRECTS"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetCreatorRedirectsResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetCreatorRedirectsResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_CREATOR_REDIRECTS_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetCreatorRedirectsResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetCreatorRedirectsResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_CREATOR_REDIRECTS_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetCreatorRedirectsResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetCreatorRedirectsResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_CREATOR_REDIRECTS_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // GetCreatorReleases - GET /creator/{ident}/releases
- &hyper::Method::GET if path.matched(paths::ID_CREATOR_IDENT_RELEASES) => {
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ Ok(response)
+ }
+
+ // GetCreatorReleases - GET /creator/{ident}/releases
+ &hyper::Method::GET if path.matched(paths::ID_CREATOR_IDENT_RELEASES) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_CREATOR_IDENT_RELEASES
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE CREATOR_IDENT_RELEASES in set but failed match against \"{}\"", path, paths::REGEX_CREATOR_IDENT_RELEASES.as_str())
);
- let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
Ok(param_ident) => match param_ident.parse::<String>() {
Ok(param_ident) => param_ident,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
- let query_params =
- form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
- .collect::<Vec<_>>();
- let param_hide = query_params
- .iter()
- .filter(|e| e.0 == "hide")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_hide = param_hide.and_then(|param_hide| param_hide.parse().ok());
-
- Box::new({
- {
- {
- Box::new(
- api_impl.get_creator_releases(
- param_ident,
- param_hide,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_hide = query_params
+ .iter()
+ .filter(|e| e.0 == "hide")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_hide = match param_hide {
+ Some(param_hide) => {
+ let param_hide = <String as std::str::FromStr>::from_str(&param_hide);
+ match param_hide {
+ Ok(param_hide) => Some(param_hide),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter hide - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter hide")),
+ }
+ }
+ None => None,
+ };
- match result {
- Ok(rsp) => match rsp {
- GetCreatorReleasesResponse::Found
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ let result = api_impl
+ .get_creator_releases(param_ident, param_hide, &context)
+ .await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetCreatorReleasesResponse::Found(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_CREATOR_RELEASES_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetCreatorReleasesResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetCreatorReleasesResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_CREATOR_RELEASES_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetCreatorReleasesResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetCreatorReleasesResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_CREATOR_RELEASES_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetCreatorReleasesResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetCreatorReleasesResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_CREATOR_RELEASES_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // GetCreatorRevision - GET /creator/rev/{rev_id}
- &hyper::Method::GET if path.matched(paths::ID_CREATOR_REV_REV_ID) => {
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ Ok(response)
+ }
+
+ // GetCreatorRevision - GET /creator/rev/{rev_id}
+ &hyper::Method::GET if path.matched(paths::ID_CREATOR_REV_REV_ID) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_CREATOR_REV_REV_ID
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE CREATOR_REV_REV_ID in set but failed match against \"{}\"", path, paths::REGEX_CREATOR_REV_REV_ID.as_str())
);
- let param_rev_id = match percent_encoding::percent_decode(path_params["rev_id"].as_bytes()).decode_utf8() {
+ let param_rev_id = match percent_encoding::percent_decode(path_params["rev_id"].as_bytes()).decode_utf8() {
Ok(param_rev_id) => match param_rev_id.parse::<String>() {
Ok(param_rev_id) => param_rev_id,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter rev_id: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["rev_id"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
- let query_params =
- form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
- .collect::<Vec<_>>();
- let param_expand = query_params
- .iter()
- .filter(|e| e.0 == "expand")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_expand = param_expand.and_then(|param_expand| param_expand.parse().ok());
- let param_hide = query_params
- .iter()
- .filter(|e| e.0 == "hide")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_hide = param_hide.and_then(|param_hide| param_hide.parse().ok());
-
- Box::new({
- {
- {
- Box::new(
- api_impl.get_creator_revision(
- param_rev_id,
- param_expand,
- param_hide,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_expand = query_params
+ .iter()
+ .filter(|e| e.0 == "expand")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_expand = match param_expand {
+ Some(param_expand) => {
+ let param_expand =
+ <String as std::str::FromStr>::from_str(&param_expand);
+ match param_expand {
+ Ok(param_expand) => Some(param_expand),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter expand - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter expand")),
+ }
+ }
+ None => None,
+ };
+ let param_hide = query_params
+ .iter()
+ .filter(|e| e.0 == "hide")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_hide = match param_hide {
+ Some(param_hide) => {
+ let param_hide = <String as std::str::FromStr>::from_str(&param_hide);
+ match param_hide {
+ Ok(param_hide) => Some(param_hide),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter hide - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter hide")),
+ }
+ }
+ None => None,
+ };
- match result {
- Ok(rsp) => match rsp {
- GetCreatorRevisionResponse::FoundEntityRevision
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ let result = api_impl
+ .get_creator_revision(param_rev_id, param_expand, param_hide, &context)
+ .await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetCreatorRevisionResponse::FoundEntityRevision(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_CREATOR_REVISION_FOUND_ENTITY_REVISION"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetCreatorRevisionResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetCreatorRevisionResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_CREATOR_REVISION_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetCreatorRevisionResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetCreatorRevisionResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_CREATOR_REVISION_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetCreatorRevisionResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetCreatorRevisionResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_CREATOR_REVISION_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // GetEditgroup - GET /editgroup/{editgroup_id}
- &hyper::Method::GET if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID) => {
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ Ok(response)
+ }
+
+ // GetEditgroup - GET /editgroup/{editgroup_id}
+ &hyper::Method::GET if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_EDITGROUP_EDITGROUP_ID
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID.as_str())
);
- let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
Ok(param_editgroup_id) => param_editgroup_id,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- Box::new({
- {
- {
- Box::new(
- api_impl.get_editgroup(
- param_editgroup_id,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ let result = api_impl.get_editgroup(param_editgroup_id, &context).await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
- match result {
- Ok(rsp) => match rsp {
- GetEditgroupResponse::Found
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ match result {
+ Ok(rsp) => match rsp {
+ GetEditgroupResponse::Found(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_EDITGROUP_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetEditgroupResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetEditgroupResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_EDITGROUP_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetEditgroupResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetEditgroupResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_EDITGROUP_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetEditgroupResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetEditgroupResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_EDITGROUP_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // GetEditgroupAnnotations - GET /editgroup/{editgroup_id}/annotations
- &hyper::Method::GET if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_ANNOTATIONS) => {
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ Ok(response)
+ }
+
+ // GetEditgroupAnnotations - GET /editgroup/{editgroup_id}/annotations
+ &hyper::Method::GET
+ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_ANNOTATIONS) =>
+ {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_EDITGROUP_EDITGROUP_ID_ANNOTATIONS
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID_ANNOTATIONS in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID_ANNOTATIONS.as_str())
);
- let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
Ok(param_editgroup_id) => param_editgroup_id,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
- let query_params =
- form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
- .collect::<Vec<_>>();
- let param_expand = query_params
- .iter()
- .filter(|e| e.0 == "expand")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_expand = param_expand.and_then(|param_expand| param_expand.parse().ok());
-
- Box::new({
- {
- {
- Box::new(
- api_impl.get_editgroup_annotations(
- param_editgroup_id,
- param_expand,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_expand = query_params
+ .iter()
+ .filter(|e| e.0 == "expand")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_expand = match param_expand {
+ Some(param_expand) => {
+ let param_expand =
+ <String as std::str::FromStr>::from_str(&param_expand);
+ match param_expand {
+ Ok(param_expand) => Some(param_expand),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter expand - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter expand")),
+ }
+ }
+ None => None,
+ };
- match result {
- Ok(rsp) => match rsp {
- GetEditgroupAnnotationsResponse::Success
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ let result = api_impl
+ .get_editgroup_annotations(param_editgroup_id, param_expand, &context)
+ .await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetEditgroupAnnotationsResponse::Success(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_EDITGROUP_ANNOTATIONS_SUCCESS"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetEditgroupAnnotationsResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetEditgroupAnnotationsResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_EDITGROUP_ANNOTATIONS_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetEditgroupAnnotationsResponse::NotAuthorized
- {
- body,
- www_authenticate
- }
- => {
- let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetEditgroupAnnotationsResponse::NotAuthorized {
+ body,
+ www_authenticate,
+ } => {
+ if let Some(www_authenticate) = www_authenticate {
+ let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
Ok(val) => val,
Err(e) => {
- return future::ok(Response::builder()
+ return Ok(Response::builder()
.status(StatusCode::INTERNAL_SERVER_ERROR)
.body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
.expect("Unable to create Internal Server Error for invalid response header"))
}
};
- *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
- response.headers_mut().insert(
- HeaderName::from_static("www_authenticate"),
- www_authenticate
- );
- response.headers_mut().insert(
+ response.headers_mut().insert(
+ HeaderName::from_static("www_authenticate"),
+ www_authenticate,
+ );
+ }
+ *response.status_mut() = StatusCode::from_u16(401)
+ .expect("Unable to turn 401 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_EDITGROUP_ANNOTATIONS_NOT_AUTHORIZED"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetEditgroupAnnotationsResponse::Forbidden
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(403).expect("Unable to turn 403 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetEditgroupAnnotationsResponse::Forbidden(body) => {
+ *response.status_mut() = StatusCode::from_u16(403)
+ .expect("Unable to turn 403 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_EDITGROUP_ANNOTATIONS_FORBIDDEN"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetEditgroupAnnotationsResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetEditgroupAnnotationsResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_EDITGROUP_ANNOTATIONS_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetEditgroupAnnotationsResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetEditgroupAnnotationsResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_EDITGROUP_ANNOTATIONS_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // GetEditgroupsReviewable - GET /editgroup/reviewable
- &hyper::Method::GET if path.matched(paths::ID_EDITGROUP_REVIEWABLE) => {
- // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
- let query_params =
- form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
- .collect::<Vec<_>>();
- let param_expand = query_params
- .iter()
- .filter(|e| e.0 == "expand")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_expand = param_expand.and_then(|param_expand| param_expand.parse().ok());
- let param_limit = query_params
- .iter()
- .filter(|e| e.0 == "limit")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_limit = param_limit.and_then(|param_limit| param_limit.parse().ok());
- let param_before = query_params
- .iter()
- .filter(|e| e.0 == "before")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_before = param_before.and_then(|param_before| param_before.parse().ok());
- let param_since = query_params
- .iter()
- .filter(|e| e.0 == "since")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_since = param_since.and_then(|param_since| param_since.parse().ok());
-
- Box::new({
- {
- {
- Box::new(
- api_impl.get_editgroups_reviewable(
- param_expand,
- param_limit,
- param_before,
- param_since,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ Ok(response)
+ }
- match result {
- Ok(rsp) => match rsp {
- GetEditgroupsReviewableResponse::Found
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ // GetEditgroupsReviewable - GET /editgroup/reviewable
+ &hyper::Method::GET if path.matched(paths::ID_EDITGROUP_REVIEWABLE) => {
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_expand = query_params
+ .iter()
+ .filter(|e| e.0 == "expand")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_expand = match param_expand {
+ Some(param_expand) => {
+ let param_expand =
+ <String as std::str::FromStr>::from_str(&param_expand);
+ match param_expand {
+ Ok(param_expand) => Some(param_expand),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter expand - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter expand")),
+ }
+ }
+ None => None,
+ };
+ let param_limit = query_params
+ .iter()
+ .filter(|e| e.0 == "limit")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_limit = match param_limit {
+ Some(param_limit) => {
+ let param_limit = <i64 as std::str::FromStr>::from_str(&param_limit);
+ match param_limit {
+ Ok(param_limit) => Some(param_limit),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter limit - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter limit")),
+ }
+ }
+ None => None,
+ };
+ let param_before = query_params
+ .iter()
+ .filter(|e| e.0 == "before")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_before = match param_before {
+ Some(param_before) => {
+ let param_before =
+ <chrono::DateTime<chrono::Utc> as std::str::FromStr>::from_str(
+ &param_before,
+ );
+ match param_before {
+ Ok(param_before) => Some(param_before),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter before - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter before")),
+ }
+ }
+ None => None,
+ };
+ let param_since = query_params
+ .iter()
+ .filter(|e| e.0 == "since")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_since = match param_since {
+ Some(param_since) => {
+ let param_since =
+ <chrono::DateTime<chrono::Utc> as std::str::FromStr>::from_str(
+ &param_since,
+ );
+ match param_since {
+ Ok(param_since) => Some(param_since),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter since - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter since")),
+ }
+ }
+ None => None,
+ };
+
+ let result = api_impl
+ .get_editgroups_reviewable(
+ param_expand,
+ param_limit,
+ param_before,
+ param_since,
+ &context,
+ )
+ .await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetEditgroupsReviewableResponse::Found(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_EDITGROUPS_REVIEWABLE_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetEditgroupsReviewableResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetEditgroupsReviewableResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_EDITGROUPS_REVIEWABLE_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetEditgroupsReviewableResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetEditgroupsReviewableResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_EDITGROUPS_REVIEWABLE_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetEditgroupsReviewableResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetEditgroupsReviewableResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_EDITGROUPS_REVIEWABLE_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // GetEditor - GET /editor/{editor_id}
- &hyper::Method::GET if path.matched(paths::ID_EDITOR_EDITOR_ID) => {
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ Ok(response)
+ }
+
+ // GetEditor - GET /editor/{editor_id}
+ &hyper::Method::GET if path.matched(paths::ID_EDITOR_EDITOR_ID) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_EDITOR_EDITOR_ID
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE EDITOR_EDITOR_ID in set but failed match against \"{}\"", path, paths::REGEX_EDITOR_EDITOR_ID.as_str())
);
- let param_editor_id = match percent_encoding::percent_decode(path_params["editor_id"].as_bytes()).decode_utf8() {
+ let param_editor_id = match percent_encoding::percent_decode(path_params["editor_id"].as_bytes()).decode_utf8() {
Ok(param_editor_id) => match param_editor_id.parse::<String>() {
Ok(param_editor_id) => param_editor_id,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter editor_id: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editor_id"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- Box::new({
- {
- {
- Box::new(
- api_impl.get_editor(
- param_editor_id,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ let result = api_impl.get_editor(param_editor_id, &context).await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
- match result {
- Ok(rsp) => match rsp {
- GetEditorResponse::Found
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ match result {
+ Ok(rsp) => {
+ match rsp {
+ GetEditorResponse::Found(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_EDITOR_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetEditorResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetEditorResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_EDITOR_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetEditorResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetEditorResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_EDITOR_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetEditorResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetEditorResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_EDITOR_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ }
+ }
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // GetEditorAnnotations - GET /editor/{editor_id}/annotations
- &hyper::Method::GET if path.matched(paths::ID_EDITOR_EDITOR_ID_ANNOTATIONS) => {
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ Ok(response)
+ }
+
+ // GetEditorAnnotations - GET /editor/{editor_id}/annotations
+ &hyper::Method::GET if path.matched(paths::ID_EDITOR_EDITOR_ID_ANNOTATIONS) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_EDITOR_EDITOR_ID_ANNOTATIONS
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE EDITOR_EDITOR_ID_ANNOTATIONS in set but failed match against \"{}\"", path, paths::REGEX_EDITOR_EDITOR_ID_ANNOTATIONS.as_str())
);
- let param_editor_id = match percent_encoding::percent_decode(path_params["editor_id"].as_bytes()).decode_utf8() {
+ let param_editor_id = match percent_encoding::percent_decode(path_params["editor_id"].as_bytes()).decode_utf8() {
Ok(param_editor_id) => match param_editor_id.parse::<String>() {
Ok(param_editor_id) => param_editor_id,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter editor_id: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editor_id"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
- let query_params =
- form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
- .collect::<Vec<_>>();
- let param_limit = query_params
- .iter()
- .filter(|e| e.0 == "limit")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_limit = param_limit.and_then(|param_limit| param_limit.parse().ok());
- let param_before = query_params
- .iter()
- .filter(|e| e.0 == "before")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_before = param_before.and_then(|param_before| param_before.parse().ok());
- let param_since = query_params
- .iter()
- .filter(|e| e.0 == "since")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_since = param_since.and_then(|param_since| param_since.parse().ok());
-
- Box::new({
- {
- {
- Box::new(
- api_impl.get_editor_annotations(
- param_editor_id,
- param_limit,
- param_before,
- param_since,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_limit = query_params
+ .iter()
+ .filter(|e| e.0 == "limit")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_limit = match param_limit {
+ Some(param_limit) => {
+ let param_limit = <i64 as std::str::FromStr>::from_str(&param_limit);
+ match param_limit {
+ Ok(param_limit) => Some(param_limit),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter limit - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter limit")),
+ }
+ }
+ None => None,
+ };
+ let param_before = query_params
+ .iter()
+ .filter(|e| e.0 == "before")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_before = match param_before {
+ Some(param_before) => {
+ let param_before =
+ <chrono::DateTime<chrono::Utc> as std::str::FromStr>::from_str(
+ &param_before,
+ );
+ match param_before {
+ Ok(param_before) => Some(param_before),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter before - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter before")),
+ }
+ }
+ None => None,
+ };
+ let param_since = query_params
+ .iter()
+ .filter(|e| e.0 == "since")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_since = match param_since {
+ Some(param_since) => {
+ let param_since =
+ <chrono::DateTime<chrono::Utc> as std::str::FromStr>::from_str(
+ &param_since,
+ );
+ match param_since {
+ Ok(param_since) => Some(param_since),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter since - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter since")),
+ }
+ }
+ None => None,
+ };
- match result {
- Ok(rsp) => match rsp {
- GetEditorAnnotationsResponse::Success
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ let result = api_impl
+ .get_editor_annotations(
+ param_editor_id,
+ param_limit,
+ param_before,
+ param_since,
+ &context,
+ )
+ .await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetEditorAnnotationsResponse::Success(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_EDITOR_ANNOTATIONS_SUCCESS"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetEditorAnnotationsResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetEditorAnnotationsResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_EDITOR_ANNOTATIONS_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetEditorAnnotationsResponse::NotAuthorized
- {
- body,
- www_authenticate
- }
- => {
- let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetEditorAnnotationsResponse::NotAuthorized {
+ body,
+ www_authenticate,
+ } => {
+ if let Some(www_authenticate) = www_authenticate {
+ let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
Ok(val) => val,
Err(e) => {
- return future::ok(Response::builder()
+ return Ok(Response::builder()
.status(StatusCode::INTERNAL_SERVER_ERROR)
.body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
.expect("Unable to create Internal Server Error for invalid response header"))
}
};
- *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
- response.headers_mut().insert(
- HeaderName::from_static("www_authenticate"),
- www_authenticate
- );
- response.headers_mut().insert(
+ response.headers_mut().insert(
+ HeaderName::from_static("www_authenticate"),
+ www_authenticate,
+ );
+ }
+ *response.status_mut() = StatusCode::from_u16(401)
+ .expect("Unable to turn 401 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_EDITOR_ANNOTATIONS_NOT_AUTHORIZED"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetEditorAnnotationsResponse::Forbidden
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(403).expect("Unable to turn 403 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetEditorAnnotationsResponse::Forbidden(body) => {
+ *response.status_mut() = StatusCode::from_u16(403)
+ .expect("Unable to turn 403 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_EDITOR_ANNOTATIONS_FORBIDDEN"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetEditorAnnotationsResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetEditorAnnotationsResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_EDITOR_ANNOTATIONS_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetEditorAnnotationsResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetEditorAnnotationsResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_EDITOR_ANNOTATIONS_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // GetEditorEditgroups - GET /editor/{editor_id}/editgroups
- &hyper::Method::GET if path.matched(paths::ID_EDITOR_EDITOR_ID_EDITGROUPS) => {
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ Ok(response)
+ }
+
+ // GetEditorEditgroups - GET /editor/{editor_id}/editgroups
+ &hyper::Method::GET if path.matched(paths::ID_EDITOR_EDITOR_ID_EDITGROUPS) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_EDITOR_EDITOR_ID_EDITGROUPS
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE EDITOR_EDITOR_ID_EDITGROUPS in set but failed match against \"{}\"", path, paths::REGEX_EDITOR_EDITOR_ID_EDITGROUPS.as_str())
);
- let param_editor_id = match percent_encoding::percent_decode(path_params["editor_id"].as_bytes()).decode_utf8() {
+ let param_editor_id = match percent_encoding::percent_decode(path_params["editor_id"].as_bytes()).decode_utf8() {
Ok(param_editor_id) => match param_editor_id.parse::<String>() {
Ok(param_editor_id) => param_editor_id,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter editor_id: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editor_id"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
- let query_params =
- form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
- .collect::<Vec<_>>();
- let param_limit = query_params
- .iter()
- .filter(|e| e.0 == "limit")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_limit = param_limit.and_then(|param_limit| param_limit.parse().ok());
- let param_before = query_params
- .iter()
- .filter(|e| e.0 == "before")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_before = param_before.and_then(|param_before| param_before.parse().ok());
- let param_since = query_params
- .iter()
- .filter(|e| e.0 == "since")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_since = param_since.and_then(|param_since| param_since.parse().ok());
-
- Box::new({
- {
- {
- Box::new(
- api_impl.get_editor_editgroups(
- param_editor_id,
- param_limit,
- param_before,
- param_since,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_limit = query_params
+ .iter()
+ .filter(|e| e.0 == "limit")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_limit = match param_limit {
+ Some(param_limit) => {
+ let param_limit = <i64 as std::str::FromStr>::from_str(&param_limit);
+ match param_limit {
+ Ok(param_limit) => Some(param_limit),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter limit - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter limit")),
+ }
+ }
+ None => None,
+ };
+ let param_before = query_params
+ .iter()
+ .filter(|e| e.0 == "before")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_before = match param_before {
+ Some(param_before) => {
+ let param_before =
+ <chrono::DateTime<chrono::Utc> as std::str::FromStr>::from_str(
+ &param_before,
+ );
+ match param_before {
+ Ok(param_before) => Some(param_before),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter before - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter before")),
+ }
+ }
+ None => None,
+ };
+ let param_since = query_params
+ .iter()
+ .filter(|e| e.0 == "since")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_since = match param_since {
+ Some(param_since) => {
+ let param_since =
+ <chrono::DateTime<chrono::Utc> as std::str::FromStr>::from_str(
+ &param_since,
+ );
+ match param_since {
+ Ok(param_since) => Some(param_since),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter since - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter since")),
+ }
+ }
+ None => None,
+ };
- match result {
- Ok(rsp) => match rsp {
- GetEditorEditgroupsResponse::Found
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ let result = api_impl
+ .get_editor_editgroups(
+ param_editor_id,
+ param_limit,
+ param_before,
+ param_since,
+ &context,
+ )
+ .await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetEditorEditgroupsResponse::Found(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_EDITOR_EDITGROUPS_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetEditorEditgroupsResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetEditorEditgroupsResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_EDITOR_EDITGROUPS_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetEditorEditgroupsResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetEditorEditgroupsResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_EDITOR_EDITGROUPS_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetEditorEditgroupsResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetEditorEditgroupsResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_EDITOR_EDITGROUPS_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // GetFile - GET /file/{ident}
- &hyper::Method::GET if path.matched(paths::ID_FILE_IDENT) => {
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params = paths::REGEX_FILE_IDENT.captures(&path).unwrap_or_else(|| {
- panic!(
- "Path {} matched RE FILE_IDENT in set but failed match against \"{}\"",
- path,
- paths::REGEX_FILE_IDENT.as_str()
- )
- });
-
- let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ Ok(response)
+ }
+
+ // GetFile - GET /file/{ident}
+ &hyper::Method::GET if path.matched(paths::ID_FILE_IDENT) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_FILE_IDENT
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE FILE_IDENT in set but failed match against \"{}\"", path, paths::REGEX_FILE_IDENT.as_str())
+ );
+
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
Ok(param_ident) => match param_ident.parse::<String>() {
Ok(param_ident) => param_ident,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
- let query_params =
- form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
- .collect::<Vec<_>>();
- let param_expand = query_params
- .iter()
- .filter(|e| e.0 == "expand")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_expand = param_expand.and_then(|param_expand| param_expand.parse().ok());
- let param_hide = query_params
- .iter()
- .filter(|e| e.0 == "hide")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_hide = param_hide.and_then(|param_hide| param_hide.parse().ok());
-
- Box::new({
- {
- {
- Box::new(
- api_impl.get_file(
- param_ident,
- param_expand,
- param_hide,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_expand = query_params
+ .iter()
+ .filter(|e| e.0 == "expand")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_expand = match param_expand {
+ Some(param_expand) => {
+ let param_expand =
+ <String as std::str::FromStr>::from_str(&param_expand);
+ match param_expand {
+ Ok(param_expand) => Some(param_expand),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter expand - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter expand")),
+ }
+ }
+ None => None,
+ };
+ let param_hide = query_params
+ .iter()
+ .filter(|e| e.0 == "hide")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_hide = match param_hide {
+ Some(param_hide) => {
+ let param_hide = <String as std::str::FromStr>::from_str(&param_hide);
+ match param_hide {
+ Ok(param_hide) => Some(param_hide),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter hide - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter hide")),
+ }
+ }
+ None => None,
+ };
- match result {
- Ok(rsp) => match rsp {
- GetFileResponse::FoundEntity
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ let result = api_impl
+ .get_file(param_ident, param_expand, param_hide, &context)
+ .await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetFileResponse::FoundEntity(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_FILE_FOUND_ENTITY"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetFileResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetFileResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_FILE_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetFileResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetFileResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_FILE_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetFileResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetFileResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_FILE_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // GetFileEdit - GET /file/edit/{edit_id}
- &hyper::Method::GET if path.matched(paths::ID_FILE_EDIT_EDIT_ID) => {
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ Ok(response)
+ }
+
+ // GetFileEdit - GET /file/edit/{edit_id}
+ &hyper::Method::GET if path.matched(paths::ID_FILE_EDIT_EDIT_ID) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_FILE_EDIT_EDIT_ID
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE FILE_EDIT_EDIT_ID in set but failed match against \"{}\"", path, paths::REGEX_FILE_EDIT_EDIT_ID.as_str())
);
- let param_edit_id = match percent_encoding::percent_decode(path_params["edit_id"].as_bytes()).decode_utf8() {
+ let param_edit_id = match percent_encoding::percent_decode(path_params["edit_id"].as_bytes()).decode_utf8() {
Ok(param_edit_id) => match param_edit_id.parse::<String>() {
Ok(param_edit_id) => param_edit_id,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter edit_id: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["edit_id"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- Box::new({
- {
- {
- Box::new(
- api_impl.get_file_edit(
- param_edit_id,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ let result = api_impl.get_file_edit(param_edit_id, &context).await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
- match result {
- Ok(rsp) => match rsp {
- GetFileEditResponse::FoundEdit
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ match result {
+ Ok(rsp) => match rsp {
+ GetFileEditResponse::FoundEdit(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_FILE_EDIT_FOUND_EDIT"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetFileEditResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetFileEditResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_FILE_EDIT_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetFileEditResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetFileEditResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_FILE_EDIT_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetFileEditResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetFileEditResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_FILE_EDIT_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // GetFileHistory - GET /file/{ident}/history
- &hyper::Method::GET if path.matched(paths::ID_FILE_IDENT_HISTORY) => {
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ Ok(response)
+ }
+
+ // GetFileHistory - GET /file/{ident}/history
+ &hyper::Method::GET if path.matched(paths::ID_FILE_IDENT_HISTORY) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_FILE_IDENT_HISTORY
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE FILE_IDENT_HISTORY in set but failed match against \"{}\"", path, paths::REGEX_FILE_IDENT_HISTORY.as_str())
);
- let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
Ok(param_ident) => match param_ident.parse::<String>() {
Ok(param_ident) => param_ident,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
- let query_params =
- form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
- .collect::<Vec<_>>();
- let param_limit = query_params
- .iter()
- .filter(|e| e.0 == "limit")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_limit = param_limit.and_then(|param_limit| param_limit.parse().ok());
-
- Box::new({
- {
- {
- Box::new(
- api_impl.get_file_history(
- param_ident,
- param_limit,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_limit = query_params
+ .iter()
+ .filter(|e| e.0 == "limit")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_limit = match param_limit {
+ Some(param_limit) => {
+ let param_limit = <i64 as std::str::FromStr>::from_str(&param_limit);
+ match param_limit {
+ Ok(param_limit) => Some(param_limit),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter limit - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter limit")),
+ }
+ }
+ None => None,
+ };
- match result {
- Ok(rsp) => match rsp {
- GetFileHistoryResponse::FoundEntityHistory
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ let result = api_impl
+ .get_file_history(param_ident, param_limit, &context)
+ .await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetFileHistoryResponse::FoundEntityHistory(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_FILE_HISTORY_FOUND_ENTITY_HISTORY"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetFileHistoryResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetFileHistoryResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_FILE_HISTORY_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetFileHistoryResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetFileHistoryResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_FILE_HISTORY_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetFileHistoryResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetFileHistoryResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_FILE_HISTORY_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // GetFileRedirects - GET /file/{ident}/redirects
- &hyper::Method::GET if path.matched(paths::ID_FILE_IDENT_REDIRECTS) => {
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ Ok(response)
+ }
+
+ // GetFileRedirects - GET /file/{ident}/redirects
+ &hyper::Method::GET if path.matched(paths::ID_FILE_IDENT_REDIRECTS) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_FILE_IDENT_REDIRECTS
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE FILE_IDENT_REDIRECTS in set but failed match against \"{}\"", path, paths::REGEX_FILE_IDENT_REDIRECTS.as_str())
);
- let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
Ok(param_ident) => match param_ident.parse::<String>() {
Ok(param_ident) => param_ident,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- Box::new({
- {
- {
- Box::new(
- api_impl.get_file_redirects(
- param_ident,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ let result = api_impl.get_file_redirects(param_ident, &context).await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
- match result {
- Ok(rsp) => match rsp {
- GetFileRedirectsResponse::FoundEntityRedirects
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ match result {
+ Ok(rsp) => match rsp {
+ GetFileRedirectsResponse::FoundEntityRedirects(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_FILE_REDIRECTS_FOUND_ENTITY_REDIRECTS"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetFileRedirectsResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetFileRedirectsResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_FILE_REDIRECTS_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetFileRedirectsResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetFileRedirectsResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_FILE_REDIRECTS_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetFileRedirectsResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetFileRedirectsResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_FILE_REDIRECTS_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // GetFileRevision - GET /file/rev/{rev_id}
- &hyper::Method::GET if path.matched(paths::ID_FILE_REV_REV_ID) => {
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ Ok(response)
+ }
+
+ // GetFileRevision - GET /file/rev/{rev_id}
+ &hyper::Method::GET if path.matched(paths::ID_FILE_REV_REV_ID) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_FILE_REV_REV_ID
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE FILE_REV_REV_ID in set but failed match against \"{}\"", path, paths::REGEX_FILE_REV_REV_ID.as_str())
);
- let param_rev_id = match percent_encoding::percent_decode(path_params["rev_id"].as_bytes()).decode_utf8() {
+ let param_rev_id = match percent_encoding::percent_decode(path_params["rev_id"].as_bytes()).decode_utf8() {
Ok(param_rev_id) => match param_rev_id.parse::<String>() {
Ok(param_rev_id) => param_rev_id,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter rev_id: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["rev_id"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
- let query_params =
- form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
- .collect::<Vec<_>>();
- let param_expand = query_params
- .iter()
- .filter(|e| e.0 == "expand")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_expand = param_expand.and_then(|param_expand| param_expand.parse().ok());
- let param_hide = query_params
- .iter()
- .filter(|e| e.0 == "hide")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_hide = param_hide.and_then(|param_hide| param_hide.parse().ok());
-
- Box::new({
- {
- {
- Box::new(
- api_impl.get_file_revision(
- param_rev_id,
- param_expand,
- param_hide,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_expand = query_params
+ .iter()
+ .filter(|e| e.0 == "expand")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_expand = match param_expand {
+ Some(param_expand) => {
+ let param_expand =
+ <String as std::str::FromStr>::from_str(&param_expand);
+ match param_expand {
+ Ok(param_expand) => Some(param_expand),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter expand - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter expand")),
+ }
+ }
+ None => None,
+ };
+ let param_hide = query_params
+ .iter()
+ .filter(|e| e.0 == "hide")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_hide = match param_hide {
+ Some(param_hide) => {
+ let param_hide = <String as std::str::FromStr>::from_str(&param_hide);
+ match param_hide {
+ Ok(param_hide) => Some(param_hide),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter hide - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter hide")),
+ }
+ }
+ None => None,
+ };
- match result {
- Ok(rsp) => match rsp {
- GetFileRevisionResponse::FoundEntityRevision
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ let result = api_impl
+ .get_file_revision(param_rev_id, param_expand, param_hide, &context)
+ .await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetFileRevisionResponse::FoundEntityRevision(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_FILE_REVISION_FOUND_ENTITY_REVISION"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetFileRevisionResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetFileRevisionResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_FILE_REVISION_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetFileRevisionResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetFileRevisionResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_FILE_REVISION_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetFileRevisionResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetFileRevisionResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_FILE_REVISION_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // GetFileset - GET /fileset/{ident}
- &hyper::Method::GET if path.matched(paths::ID_FILESET_IDENT) => {
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ Ok(response)
+ }
+
+ // GetFileset - GET /fileset/{ident}
+ &hyper::Method::GET if path.matched(paths::ID_FILESET_IDENT) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_FILESET_IDENT
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE FILESET_IDENT in set but failed match against \"{}\"", path, paths::REGEX_FILESET_IDENT.as_str())
);
- let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
Ok(param_ident) => match param_ident.parse::<String>() {
Ok(param_ident) => param_ident,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
- let query_params =
- form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
- .collect::<Vec<_>>();
- let param_expand = query_params
- .iter()
- .filter(|e| e.0 == "expand")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_expand = param_expand.and_then(|param_expand| param_expand.parse().ok());
- let param_hide = query_params
- .iter()
- .filter(|e| e.0 == "hide")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_hide = param_hide.and_then(|param_hide| param_hide.parse().ok());
-
- Box::new({
- {
- {
- Box::new(
- api_impl.get_fileset(
- param_ident,
- param_expand,
- param_hide,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_expand = query_params
+ .iter()
+ .filter(|e| e.0 == "expand")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_expand = match param_expand {
+ Some(param_expand) => {
+ let param_expand =
+ <String as std::str::FromStr>::from_str(&param_expand);
+ match param_expand {
+ Ok(param_expand) => Some(param_expand),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter expand - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter expand")),
+ }
+ }
+ None => None,
+ };
+ let param_hide = query_params
+ .iter()
+ .filter(|e| e.0 == "hide")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_hide = match param_hide {
+ Some(param_hide) => {
+ let param_hide = <String as std::str::FromStr>::from_str(&param_hide);
+ match param_hide {
+ Ok(param_hide) => Some(param_hide),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter hide - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter hide")),
+ }
+ }
+ None => None,
+ };
- match result {
- Ok(rsp) => match rsp {
- GetFilesetResponse::FoundEntity
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ let result = api_impl
+ .get_fileset(param_ident, param_expand, param_hide, &context)
+ .await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetFilesetResponse::FoundEntity(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_FILESET_FOUND_ENTITY"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetFilesetResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetFilesetResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_FILESET_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetFilesetResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetFilesetResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_FILESET_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetFilesetResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetFilesetResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_FILESET_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // GetFilesetEdit - GET /fileset/edit/{edit_id}
- &hyper::Method::GET if path.matched(paths::ID_FILESET_EDIT_EDIT_ID) => {
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ Ok(response)
+ }
+
+ // GetFilesetEdit - GET /fileset/edit/{edit_id}
+ &hyper::Method::GET if path.matched(paths::ID_FILESET_EDIT_EDIT_ID) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_FILESET_EDIT_EDIT_ID
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE FILESET_EDIT_EDIT_ID in set but failed match against \"{}\"", path, paths::REGEX_FILESET_EDIT_EDIT_ID.as_str())
);
- let param_edit_id = match percent_encoding::percent_decode(path_params["edit_id"].as_bytes()).decode_utf8() {
+ let param_edit_id = match percent_encoding::percent_decode(path_params["edit_id"].as_bytes()).decode_utf8() {
Ok(param_edit_id) => match param_edit_id.parse::<String>() {
Ok(param_edit_id) => param_edit_id,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter edit_id: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["edit_id"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- Box::new({
- {
- {
- Box::new(
- api_impl.get_fileset_edit(
- param_edit_id,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ let result = api_impl.get_fileset_edit(param_edit_id, &context).await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
- match result {
- Ok(rsp) => match rsp {
- GetFilesetEditResponse::FoundEdit
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ match result {
+ Ok(rsp) => match rsp {
+ GetFilesetEditResponse::FoundEdit(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_FILESET_EDIT_FOUND_EDIT"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetFilesetEditResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetFilesetEditResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_FILESET_EDIT_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetFilesetEditResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetFilesetEditResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_FILESET_EDIT_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetFilesetEditResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetFilesetEditResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_FILESET_EDIT_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // GetFilesetHistory - GET /fileset/{ident}/history
- &hyper::Method::GET if path.matched(paths::ID_FILESET_IDENT_HISTORY) => {
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ Ok(response)
+ }
+
+ // GetFilesetHistory - GET /fileset/{ident}/history
+ &hyper::Method::GET if path.matched(paths::ID_FILESET_IDENT_HISTORY) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_FILESET_IDENT_HISTORY
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE FILESET_IDENT_HISTORY in set but failed match against \"{}\"", path, paths::REGEX_FILESET_IDENT_HISTORY.as_str())
);
- let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
Ok(param_ident) => match param_ident.parse::<String>() {
Ok(param_ident) => param_ident,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
- let query_params =
- form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
- .collect::<Vec<_>>();
- let param_limit = query_params
- .iter()
- .filter(|e| e.0 == "limit")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_limit = param_limit.and_then(|param_limit| param_limit.parse().ok());
-
- Box::new({
- {
- {
- Box::new(
- api_impl.get_fileset_history(
- param_ident,
- param_limit,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_limit = query_params
+ .iter()
+ .filter(|e| e.0 == "limit")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_limit = match param_limit {
+ Some(param_limit) => {
+ let param_limit = <i64 as std::str::FromStr>::from_str(&param_limit);
+ match param_limit {
+ Ok(param_limit) => Some(param_limit),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter limit - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter limit")),
+ }
+ }
+ None => None,
+ };
- match result {
- Ok(rsp) => match rsp {
- GetFilesetHistoryResponse::FoundEntityHistory
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ let result = api_impl
+ .get_fileset_history(param_ident, param_limit, &context)
+ .await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetFilesetHistoryResponse::FoundEntityHistory(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_FILESET_HISTORY_FOUND_ENTITY_HISTORY"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetFilesetHistoryResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetFilesetHistoryResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_FILESET_HISTORY_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetFilesetHistoryResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetFilesetHistoryResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_FILESET_HISTORY_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetFilesetHistoryResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetFilesetHistoryResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_FILESET_HISTORY_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // GetFilesetRedirects - GET /fileset/{ident}/redirects
- &hyper::Method::GET if path.matched(paths::ID_FILESET_IDENT_REDIRECTS) => {
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ Ok(response)
+ }
+
+ // GetFilesetRedirects - GET /fileset/{ident}/redirects
+ &hyper::Method::GET if path.matched(paths::ID_FILESET_IDENT_REDIRECTS) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_FILESET_IDENT_REDIRECTS
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE FILESET_IDENT_REDIRECTS in set but failed match against \"{}\"", path, paths::REGEX_FILESET_IDENT_REDIRECTS.as_str())
);
- let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
Ok(param_ident) => match param_ident.parse::<String>() {
Ok(param_ident) => param_ident,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- Box::new({
- {
- {
- Box::new(
- api_impl.get_fileset_redirects(
- param_ident,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ let result = api_impl.get_fileset_redirects(param_ident, &context).await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
- match result {
- Ok(rsp) => match rsp {
- GetFilesetRedirectsResponse::FoundEntityRedirects
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ match result {
+ Ok(rsp) => match rsp {
+ GetFilesetRedirectsResponse::FoundEntityRedirects(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_FILESET_REDIRECTS_FOUND_ENTITY_REDIRECTS"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetFilesetRedirectsResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetFilesetRedirectsResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_FILESET_REDIRECTS_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetFilesetRedirectsResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetFilesetRedirectsResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_FILESET_REDIRECTS_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetFilesetRedirectsResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetFilesetRedirectsResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_FILESET_REDIRECTS_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // GetFilesetRevision - GET /fileset/rev/{rev_id}
- &hyper::Method::GET if path.matched(paths::ID_FILESET_REV_REV_ID) => {
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ Ok(response)
+ }
+
+ // GetFilesetRevision - GET /fileset/rev/{rev_id}
+ &hyper::Method::GET if path.matched(paths::ID_FILESET_REV_REV_ID) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_FILESET_REV_REV_ID
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE FILESET_REV_REV_ID in set but failed match against \"{}\"", path, paths::REGEX_FILESET_REV_REV_ID.as_str())
);
- let param_rev_id = match percent_encoding::percent_decode(path_params["rev_id"].as_bytes()).decode_utf8() {
+ let param_rev_id = match percent_encoding::percent_decode(path_params["rev_id"].as_bytes()).decode_utf8() {
Ok(param_rev_id) => match param_rev_id.parse::<String>() {
Ok(param_rev_id) => param_rev_id,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter rev_id: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["rev_id"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
- let query_params =
- form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
- .collect::<Vec<_>>();
- let param_expand = query_params
- .iter()
- .filter(|e| e.0 == "expand")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_expand = param_expand.and_then(|param_expand| param_expand.parse().ok());
- let param_hide = query_params
- .iter()
- .filter(|e| e.0 == "hide")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_hide = param_hide.and_then(|param_hide| param_hide.parse().ok());
-
- Box::new({
- {
- {
- Box::new(
- api_impl.get_fileset_revision(
- param_rev_id,
- param_expand,
- param_hide,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_expand = query_params
+ .iter()
+ .filter(|e| e.0 == "expand")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_expand = match param_expand {
+ Some(param_expand) => {
+ let param_expand =
+ <String as std::str::FromStr>::from_str(&param_expand);
+ match param_expand {
+ Ok(param_expand) => Some(param_expand),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter expand - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter expand")),
+ }
+ }
+ None => None,
+ };
+ let param_hide = query_params
+ .iter()
+ .filter(|e| e.0 == "hide")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_hide = match param_hide {
+ Some(param_hide) => {
+ let param_hide = <String as std::str::FromStr>::from_str(&param_hide);
+ match param_hide {
+ Ok(param_hide) => Some(param_hide),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter hide - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter hide")),
+ }
+ }
+ None => None,
+ };
- match result {
- Ok(rsp) => match rsp {
- GetFilesetRevisionResponse::FoundEntityRevision
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ let result = api_impl
+ .get_fileset_revision(param_rev_id, param_expand, param_hide, &context)
+ .await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetFilesetRevisionResponse::FoundEntityRevision(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_FILESET_REVISION_FOUND_ENTITY_REVISION"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetFilesetRevisionResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetFilesetRevisionResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_FILESET_REVISION_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetFilesetRevisionResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetFilesetRevisionResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_FILESET_REVISION_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetFilesetRevisionResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetFilesetRevisionResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_FILESET_REVISION_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // GetRelease - GET /release/{ident}
- &hyper::Method::GET if path.matched(paths::ID_RELEASE_IDENT) => {
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ Ok(response)
+ }
+
+ // GetRelease - GET /release/{ident}
+ &hyper::Method::GET if path.matched(paths::ID_RELEASE_IDENT) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_RELEASE_IDENT
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE RELEASE_IDENT in set but failed match against \"{}\"", path, paths::REGEX_RELEASE_IDENT.as_str())
);
- let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
Ok(param_ident) => match param_ident.parse::<String>() {
Ok(param_ident) => param_ident,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
- let query_params =
- form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
- .collect::<Vec<_>>();
- let param_expand = query_params
- .iter()
- .filter(|e| e.0 == "expand")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_expand = param_expand.and_then(|param_expand| param_expand.parse().ok());
- let param_hide = query_params
- .iter()
- .filter(|e| e.0 == "hide")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_hide = param_hide.and_then(|param_hide| param_hide.parse().ok());
-
- Box::new({
- {
- {
- Box::new(
- api_impl.get_release(
- param_ident,
- param_expand,
- param_hide,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_expand = query_params
+ .iter()
+ .filter(|e| e.0 == "expand")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_expand = match param_expand {
+ Some(param_expand) => {
+ let param_expand =
+ <String as std::str::FromStr>::from_str(&param_expand);
+ match param_expand {
+ Ok(param_expand) => Some(param_expand),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter expand - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter expand")),
+ }
+ }
+ None => None,
+ };
+ let param_hide = query_params
+ .iter()
+ .filter(|e| e.0 == "hide")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_hide = match param_hide {
+ Some(param_hide) => {
+ let param_hide = <String as std::str::FromStr>::from_str(&param_hide);
+ match param_hide {
+ Ok(param_hide) => Some(param_hide),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter hide - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter hide")),
+ }
+ }
+ None => None,
+ };
- match result {
- Ok(rsp) => match rsp {
- GetReleaseResponse::FoundEntity
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ let result = api_impl
+ .get_release(param_ident, param_expand, param_hide, &context)
+ .await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetReleaseResponse::FoundEntity(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_RELEASE_FOUND_ENTITY"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetReleaseResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetReleaseResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_RELEASE_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetReleaseResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetReleaseResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_RELEASE_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetReleaseResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetReleaseResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_RELEASE_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // GetReleaseEdit - GET /release/edit/{edit_id}
- &hyper::Method::GET if path.matched(paths::ID_RELEASE_EDIT_EDIT_ID) => {
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ Ok(response)
+ }
+
+ // GetReleaseEdit - GET /release/edit/{edit_id}
+ &hyper::Method::GET if path.matched(paths::ID_RELEASE_EDIT_EDIT_ID) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_RELEASE_EDIT_EDIT_ID
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE RELEASE_EDIT_EDIT_ID in set but failed match against \"{}\"", path, paths::REGEX_RELEASE_EDIT_EDIT_ID.as_str())
);
- let param_edit_id = match percent_encoding::percent_decode(path_params["edit_id"].as_bytes()).decode_utf8() {
+ let param_edit_id = match percent_encoding::percent_decode(path_params["edit_id"].as_bytes()).decode_utf8() {
Ok(param_edit_id) => match param_edit_id.parse::<String>() {
Ok(param_edit_id) => param_edit_id,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter edit_id: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["edit_id"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- Box::new({
- {
- {
- Box::new(
- api_impl.get_release_edit(
- param_edit_id,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ let result = api_impl.get_release_edit(param_edit_id, &context).await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
- match result {
- Ok(rsp) => match rsp {
- GetReleaseEditResponse::FoundEdit
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ match result {
+ Ok(rsp) => match rsp {
+ GetReleaseEditResponse::FoundEdit(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_RELEASE_EDIT_FOUND_EDIT"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetReleaseEditResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetReleaseEditResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_RELEASE_EDIT_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetReleaseEditResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetReleaseEditResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_RELEASE_EDIT_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetReleaseEditResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetReleaseEditResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_RELEASE_EDIT_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // GetReleaseFiles - GET /release/{ident}/files
- &hyper::Method::GET if path.matched(paths::ID_RELEASE_IDENT_FILES) => {
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ Ok(response)
+ }
+
+ // GetReleaseFiles - GET /release/{ident}/files
+ &hyper::Method::GET if path.matched(paths::ID_RELEASE_IDENT_FILES) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_RELEASE_IDENT_FILES
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE RELEASE_IDENT_FILES in set but failed match against \"{}\"", path, paths::REGEX_RELEASE_IDENT_FILES.as_str())
);
- let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
Ok(param_ident) => match param_ident.parse::<String>() {
Ok(param_ident) => param_ident,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
- let query_params =
- form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
- .collect::<Vec<_>>();
- let param_hide = query_params
- .iter()
- .filter(|e| e.0 == "hide")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_hide = param_hide.and_then(|param_hide| param_hide.parse().ok());
-
- Box::new({
- {
- {
- Box::new(
- api_impl.get_release_files(
- param_ident,
- param_hide,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_hide = query_params
+ .iter()
+ .filter(|e| e.0 == "hide")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_hide = match param_hide {
+ Some(param_hide) => {
+ let param_hide = <String as std::str::FromStr>::from_str(&param_hide);
+ match param_hide {
+ Ok(param_hide) => Some(param_hide),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter hide - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter hide")),
+ }
+ }
+ None => None,
+ };
- match result {
- Ok(rsp) => match rsp {
- GetReleaseFilesResponse::Found
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ let result = api_impl
+ .get_release_files(param_ident, param_hide, &context)
+ .await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetReleaseFilesResponse::Found(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_RELEASE_FILES_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetReleaseFilesResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetReleaseFilesResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_RELEASE_FILES_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetReleaseFilesResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetReleaseFilesResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_RELEASE_FILES_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetReleaseFilesResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetReleaseFilesResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_RELEASE_FILES_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // GetReleaseFilesets - GET /release/{ident}/filesets
- &hyper::Method::GET if path.matched(paths::ID_RELEASE_IDENT_FILESETS) => {
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ Ok(response)
+ }
+
+ // GetReleaseFilesets - GET /release/{ident}/filesets
+ &hyper::Method::GET if path.matched(paths::ID_RELEASE_IDENT_FILESETS) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_RELEASE_IDENT_FILESETS
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE RELEASE_IDENT_FILESETS in set but failed match against \"{}\"", path, paths::REGEX_RELEASE_IDENT_FILESETS.as_str())
);
- let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
Ok(param_ident) => match param_ident.parse::<String>() {
Ok(param_ident) => param_ident,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
- let query_params =
- form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
- .collect::<Vec<_>>();
- let param_hide = query_params
- .iter()
- .filter(|e| e.0 == "hide")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_hide = param_hide.and_then(|param_hide| param_hide.parse().ok());
-
- Box::new({
- {
- {
- Box::new(
- api_impl.get_release_filesets(
- param_ident,
- param_hide,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_hide = query_params
+ .iter()
+ .filter(|e| e.0 == "hide")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_hide = match param_hide {
+ Some(param_hide) => {
+ let param_hide = <String as std::str::FromStr>::from_str(&param_hide);
+ match param_hide {
+ Ok(param_hide) => Some(param_hide),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter hide - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter hide")),
+ }
+ }
+ None => None,
+ };
- match result {
- Ok(rsp) => match rsp {
- GetReleaseFilesetsResponse::Found
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ let result = api_impl
+ .get_release_filesets(param_ident, param_hide, &context)
+ .await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetReleaseFilesetsResponse::Found(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_RELEASE_FILESETS_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetReleaseFilesetsResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetReleaseFilesetsResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_RELEASE_FILESETS_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetReleaseFilesetsResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetReleaseFilesetsResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_RELEASE_FILESETS_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetReleaseFilesetsResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetReleaseFilesetsResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_RELEASE_FILESETS_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // GetReleaseHistory - GET /release/{ident}/history
- &hyper::Method::GET if path.matched(paths::ID_RELEASE_IDENT_HISTORY) => {
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ Ok(response)
+ }
+
+ // GetReleaseHistory - GET /release/{ident}/history
+ &hyper::Method::GET if path.matched(paths::ID_RELEASE_IDENT_HISTORY) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_RELEASE_IDENT_HISTORY
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE RELEASE_IDENT_HISTORY in set but failed match against \"{}\"", path, paths::REGEX_RELEASE_IDENT_HISTORY.as_str())
);
- let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
Ok(param_ident) => match param_ident.parse::<String>() {
Ok(param_ident) => param_ident,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
- let query_params =
- form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
- .collect::<Vec<_>>();
- let param_limit = query_params
- .iter()
- .filter(|e| e.0 == "limit")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_limit = param_limit.and_then(|param_limit| param_limit.parse().ok());
-
- Box::new({
- {
- {
- Box::new(
- api_impl.get_release_history(
- param_ident,
- param_limit,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_limit = query_params
+ .iter()
+ .filter(|e| e.0 == "limit")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_limit = match param_limit {
+ Some(param_limit) => {
+ let param_limit = <i64 as std::str::FromStr>::from_str(&param_limit);
+ match param_limit {
+ Ok(param_limit) => Some(param_limit),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter limit - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter limit")),
+ }
+ }
+ None => None,
+ };
- match result {
- Ok(rsp) => match rsp {
- GetReleaseHistoryResponse::FoundEntityHistory
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ let result = api_impl
+ .get_release_history(param_ident, param_limit, &context)
+ .await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetReleaseHistoryResponse::FoundEntityHistory(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_RELEASE_HISTORY_FOUND_ENTITY_HISTORY"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetReleaseHistoryResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetReleaseHistoryResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_RELEASE_HISTORY_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetReleaseHistoryResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetReleaseHistoryResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_RELEASE_HISTORY_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetReleaseHistoryResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetReleaseHistoryResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_RELEASE_HISTORY_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // GetReleaseRedirects - GET /release/{ident}/redirects
- &hyper::Method::GET if path.matched(paths::ID_RELEASE_IDENT_REDIRECTS) => {
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ Ok(response)
+ }
+
+ // GetReleaseRedirects - GET /release/{ident}/redirects
+ &hyper::Method::GET if path.matched(paths::ID_RELEASE_IDENT_REDIRECTS) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_RELEASE_IDENT_REDIRECTS
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE RELEASE_IDENT_REDIRECTS in set but failed match against \"{}\"", path, paths::REGEX_RELEASE_IDENT_REDIRECTS.as_str())
);
- let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
Ok(param_ident) => match param_ident.parse::<String>() {
Ok(param_ident) => param_ident,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- Box::new({
- {
- {
- Box::new(
- api_impl.get_release_redirects(
- param_ident,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ let result = api_impl.get_release_redirects(param_ident, &context).await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
- match result {
- Ok(rsp) => match rsp {
- GetReleaseRedirectsResponse::FoundEntityRedirects
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ match result {
+ Ok(rsp) => match rsp {
+ GetReleaseRedirectsResponse::FoundEntityRedirects(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_RELEASE_REDIRECTS_FOUND_ENTITY_REDIRECTS"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetReleaseRedirectsResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetReleaseRedirectsResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_RELEASE_REDIRECTS_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetReleaseRedirectsResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetReleaseRedirectsResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_RELEASE_REDIRECTS_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetReleaseRedirectsResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetReleaseRedirectsResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_RELEASE_REDIRECTS_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // GetReleaseRevision - GET /release/rev/{rev_id}
- &hyper::Method::GET if path.matched(paths::ID_RELEASE_REV_REV_ID) => {
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ Ok(response)
+ }
+
+ // GetReleaseRevision - GET /release/rev/{rev_id}
+ &hyper::Method::GET if path.matched(paths::ID_RELEASE_REV_REV_ID) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_RELEASE_REV_REV_ID
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE RELEASE_REV_REV_ID in set but failed match against \"{}\"", path, paths::REGEX_RELEASE_REV_REV_ID.as_str())
);
- let param_rev_id = match percent_encoding::percent_decode(path_params["rev_id"].as_bytes()).decode_utf8() {
+ let param_rev_id = match percent_encoding::percent_decode(path_params["rev_id"].as_bytes()).decode_utf8() {
Ok(param_rev_id) => match param_rev_id.parse::<String>() {
Ok(param_rev_id) => param_rev_id,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter rev_id: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["rev_id"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
- let query_params =
- form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
- .collect::<Vec<_>>();
- let param_expand = query_params
- .iter()
- .filter(|e| e.0 == "expand")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_expand = param_expand.and_then(|param_expand| param_expand.parse().ok());
- let param_hide = query_params
- .iter()
- .filter(|e| e.0 == "hide")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_hide = param_hide.and_then(|param_hide| param_hide.parse().ok());
-
- Box::new({
- {
- {
- Box::new(
- api_impl.get_release_revision(
- param_rev_id,
- param_expand,
- param_hide,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_expand = query_params
+ .iter()
+ .filter(|e| e.0 == "expand")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_expand = match param_expand {
+ Some(param_expand) => {
+ let param_expand =
+ <String as std::str::FromStr>::from_str(&param_expand);
+ match param_expand {
+ Ok(param_expand) => Some(param_expand),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter expand - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter expand")),
+ }
+ }
+ None => None,
+ };
+ let param_hide = query_params
+ .iter()
+ .filter(|e| e.0 == "hide")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_hide = match param_hide {
+ Some(param_hide) => {
+ let param_hide = <String as std::str::FromStr>::from_str(&param_hide);
+ match param_hide {
+ Ok(param_hide) => Some(param_hide),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter hide - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter hide")),
+ }
+ }
+ None => None,
+ };
- match result {
- Ok(rsp) => match rsp {
- GetReleaseRevisionResponse::FoundEntityRevision
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ let result = api_impl
+ .get_release_revision(param_rev_id, param_expand, param_hide, &context)
+ .await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetReleaseRevisionResponse::FoundEntityRevision(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_RELEASE_REVISION_FOUND_ENTITY_REVISION"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetReleaseRevisionResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetReleaseRevisionResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_RELEASE_REVISION_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetReleaseRevisionResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetReleaseRevisionResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_RELEASE_REVISION_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetReleaseRevisionResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetReleaseRevisionResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_RELEASE_REVISION_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // GetReleaseWebcaptures - GET /release/{ident}/webcaptures
- &hyper::Method::GET if path.matched(paths::ID_RELEASE_IDENT_WEBCAPTURES) => {
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ Ok(response)
+ }
+
+ // GetReleaseWebcaptures - GET /release/{ident}/webcaptures
+ &hyper::Method::GET if path.matched(paths::ID_RELEASE_IDENT_WEBCAPTURES) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_RELEASE_IDENT_WEBCAPTURES
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE RELEASE_IDENT_WEBCAPTURES in set but failed match against \"{}\"", path, paths::REGEX_RELEASE_IDENT_WEBCAPTURES.as_str())
);
- let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
Ok(param_ident) => match param_ident.parse::<String>() {
Ok(param_ident) => param_ident,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
- let query_params =
- form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
- .collect::<Vec<_>>();
- let param_hide = query_params
- .iter()
- .filter(|e| e.0 == "hide")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_hide = param_hide.and_then(|param_hide| param_hide.parse().ok());
-
- Box::new({
- {
- {
- Box::new(
- api_impl.get_release_webcaptures(
- param_ident,
- param_hide,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_hide = query_params
+ .iter()
+ .filter(|e| e.0 == "hide")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_hide = match param_hide {
+ Some(param_hide) => {
+ let param_hide = <String as std::str::FromStr>::from_str(&param_hide);
+ match param_hide {
+ Ok(param_hide) => Some(param_hide),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter hide - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter hide")),
+ }
+ }
+ None => None,
+ };
- match result {
- Ok(rsp) => match rsp {
- GetReleaseWebcapturesResponse::Found
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ let result = api_impl
+ .get_release_webcaptures(param_ident, param_hide, &context)
+ .await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetReleaseWebcapturesResponse::Found(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_RELEASE_WEBCAPTURES_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetReleaseWebcapturesResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetReleaseWebcapturesResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_RELEASE_WEBCAPTURES_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetReleaseWebcapturesResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetReleaseWebcapturesResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_RELEASE_WEBCAPTURES_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetReleaseWebcapturesResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetReleaseWebcapturesResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_RELEASE_WEBCAPTURES_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // GetWebcapture - GET /webcapture/{ident}
- &hyper::Method::GET if path.matched(paths::ID_WEBCAPTURE_IDENT) => {
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ Ok(response)
+ }
+
+ // GetWebcapture - GET /webcapture/{ident}
+ &hyper::Method::GET if path.matched(paths::ID_WEBCAPTURE_IDENT) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_WEBCAPTURE_IDENT
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE WEBCAPTURE_IDENT in set but failed match against \"{}\"", path, paths::REGEX_WEBCAPTURE_IDENT.as_str())
);
- let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
Ok(param_ident) => match param_ident.parse::<String>() {
Ok(param_ident) => param_ident,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
- let query_params =
- form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
- .collect::<Vec<_>>();
- let param_expand = query_params
- .iter()
- .filter(|e| e.0 == "expand")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_expand = param_expand.and_then(|param_expand| param_expand.parse().ok());
- let param_hide = query_params
- .iter()
- .filter(|e| e.0 == "hide")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_hide = param_hide.and_then(|param_hide| param_hide.parse().ok());
-
- Box::new({
- {
- {
- Box::new(
- api_impl.get_webcapture(
- param_ident,
- param_expand,
- param_hide,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_expand = query_params
+ .iter()
+ .filter(|e| e.0 == "expand")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_expand = match param_expand {
+ Some(param_expand) => {
+ let param_expand =
+ <String as std::str::FromStr>::from_str(&param_expand);
+ match param_expand {
+ Ok(param_expand) => Some(param_expand),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter expand - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter expand")),
+ }
+ }
+ None => None,
+ };
+ let param_hide = query_params
+ .iter()
+ .filter(|e| e.0 == "hide")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_hide = match param_hide {
+ Some(param_hide) => {
+ let param_hide = <String as std::str::FromStr>::from_str(&param_hide);
+ match param_hide {
+ Ok(param_hide) => Some(param_hide),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter hide - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter hide")),
+ }
+ }
+ None => None,
+ };
- match result {
- Ok(rsp) => match rsp {
- GetWebcaptureResponse::FoundEntity
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ let result = api_impl
+ .get_webcapture(param_ident, param_expand, param_hide, &context)
+ .await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetWebcaptureResponse::FoundEntity(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_WEBCAPTURE_FOUND_ENTITY"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetWebcaptureResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetWebcaptureResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_WEBCAPTURE_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetWebcaptureResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetWebcaptureResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_WEBCAPTURE_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetWebcaptureResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetWebcaptureResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_WEBCAPTURE_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // GetWebcaptureEdit - GET /webcapture/edit/{edit_id}
- &hyper::Method::GET if path.matched(paths::ID_WEBCAPTURE_EDIT_EDIT_ID) => {
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ Ok(response)
+ }
+
+ // GetWebcaptureEdit - GET /webcapture/edit/{edit_id}
+ &hyper::Method::GET if path.matched(paths::ID_WEBCAPTURE_EDIT_EDIT_ID) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_WEBCAPTURE_EDIT_EDIT_ID
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE WEBCAPTURE_EDIT_EDIT_ID in set but failed match against \"{}\"", path, paths::REGEX_WEBCAPTURE_EDIT_EDIT_ID.as_str())
);
- let param_edit_id = match percent_encoding::percent_decode(path_params["edit_id"].as_bytes()).decode_utf8() {
+ let param_edit_id = match percent_encoding::percent_decode(path_params["edit_id"].as_bytes()).decode_utf8() {
Ok(param_edit_id) => match param_edit_id.parse::<String>() {
Ok(param_edit_id) => param_edit_id,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter edit_id: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["edit_id"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- Box::new({
- {
- {
- Box::new(
- api_impl.get_webcapture_edit(
- param_edit_id,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ let result = api_impl.get_webcapture_edit(param_edit_id, &context).await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
- match result {
- Ok(rsp) => match rsp {
- GetWebcaptureEditResponse::FoundEdit
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ match result {
+ Ok(rsp) => match rsp {
+ GetWebcaptureEditResponse::FoundEdit(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_WEBCAPTURE_EDIT_FOUND_EDIT"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetWebcaptureEditResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetWebcaptureEditResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_WEBCAPTURE_EDIT_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetWebcaptureEditResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetWebcaptureEditResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_WEBCAPTURE_EDIT_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetWebcaptureEditResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetWebcaptureEditResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_WEBCAPTURE_EDIT_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // GetWebcaptureHistory - GET /webcapture/{ident}/history
- &hyper::Method::GET if path.matched(paths::ID_WEBCAPTURE_IDENT_HISTORY) => {
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ Ok(response)
+ }
+
+ // GetWebcaptureHistory - GET /webcapture/{ident}/history
+ &hyper::Method::GET if path.matched(paths::ID_WEBCAPTURE_IDENT_HISTORY) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_WEBCAPTURE_IDENT_HISTORY
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE WEBCAPTURE_IDENT_HISTORY in set but failed match against \"{}\"", path, paths::REGEX_WEBCAPTURE_IDENT_HISTORY.as_str())
);
- let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
Ok(param_ident) => match param_ident.parse::<String>() {
Ok(param_ident) => param_ident,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
- let query_params =
- form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
- .collect::<Vec<_>>();
- let param_limit = query_params
- .iter()
- .filter(|e| e.0 == "limit")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_limit = param_limit.and_then(|param_limit| param_limit.parse().ok());
-
- Box::new({
- {
- {
- Box::new(
- api_impl.get_webcapture_history(
- param_ident,
- param_limit,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_limit = query_params
+ .iter()
+ .filter(|e| e.0 == "limit")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_limit = match param_limit {
+ Some(param_limit) => {
+ let param_limit = <i64 as std::str::FromStr>::from_str(&param_limit);
+ match param_limit {
+ Ok(param_limit) => Some(param_limit),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter limit - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter limit")),
+ }
+ }
+ None => None,
+ };
- match result {
- Ok(rsp) => match rsp {
- GetWebcaptureHistoryResponse::FoundEntityHistory
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ let result = api_impl
+ .get_webcapture_history(param_ident, param_limit, &context)
+ .await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetWebcaptureHistoryResponse::FoundEntityHistory(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_WEBCAPTURE_HISTORY_FOUND_ENTITY_HISTORY"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetWebcaptureHistoryResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetWebcaptureHistoryResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_WEBCAPTURE_HISTORY_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetWebcaptureHistoryResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetWebcaptureHistoryResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_WEBCAPTURE_HISTORY_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetWebcaptureHistoryResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetWebcaptureHistoryResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_WEBCAPTURE_HISTORY_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // GetWebcaptureRedirects - GET /webcapture/{ident}/redirects
- &hyper::Method::GET if path.matched(paths::ID_WEBCAPTURE_IDENT_REDIRECTS) => {
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ Ok(response)
+ }
+
+ // GetWebcaptureRedirects - GET /webcapture/{ident}/redirects
+ &hyper::Method::GET if path.matched(paths::ID_WEBCAPTURE_IDENT_REDIRECTS) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_WEBCAPTURE_IDENT_REDIRECTS
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE WEBCAPTURE_IDENT_REDIRECTS in set but failed match against \"{}\"", path, paths::REGEX_WEBCAPTURE_IDENT_REDIRECTS.as_str())
);
- let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
Ok(param_ident) => match param_ident.parse::<String>() {
Ok(param_ident) => param_ident,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- Box::new({
- {
- {
- Box::new(
- api_impl.get_webcapture_redirects(
- param_ident,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ let result = api_impl
+ .get_webcapture_redirects(param_ident, &context)
+ .await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
- match result {
- Ok(rsp) => match rsp {
- GetWebcaptureRedirectsResponse::FoundEntityRedirects
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ match result {
+ Ok(rsp) => match rsp {
+ GetWebcaptureRedirectsResponse::FoundEntityRedirects(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_WEBCAPTURE_REDIRECTS_FOUND_ENTITY_REDIRECTS"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetWebcaptureRedirectsResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetWebcaptureRedirectsResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_WEBCAPTURE_REDIRECTS_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetWebcaptureRedirectsResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetWebcaptureRedirectsResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_WEBCAPTURE_REDIRECTS_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetWebcaptureRedirectsResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetWebcaptureRedirectsResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_WEBCAPTURE_REDIRECTS_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // GetWebcaptureRevision - GET /webcapture/rev/{rev_id}
- &hyper::Method::GET if path.matched(paths::ID_WEBCAPTURE_REV_REV_ID) => {
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ Ok(response)
+ }
+
+ // GetWebcaptureRevision - GET /webcapture/rev/{rev_id}
+ &hyper::Method::GET if path.matched(paths::ID_WEBCAPTURE_REV_REV_ID) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_WEBCAPTURE_REV_REV_ID
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE WEBCAPTURE_REV_REV_ID in set but failed match against \"{}\"", path, paths::REGEX_WEBCAPTURE_REV_REV_ID.as_str())
);
- let param_rev_id = match percent_encoding::percent_decode(path_params["rev_id"].as_bytes()).decode_utf8() {
+ let param_rev_id = match percent_encoding::percent_decode(path_params["rev_id"].as_bytes()).decode_utf8() {
Ok(param_rev_id) => match param_rev_id.parse::<String>() {
Ok(param_rev_id) => param_rev_id,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter rev_id: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["rev_id"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
- let query_params =
- form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
- .collect::<Vec<_>>();
- let param_expand = query_params
- .iter()
- .filter(|e| e.0 == "expand")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_expand = param_expand.and_then(|param_expand| param_expand.parse().ok());
- let param_hide = query_params
- .iter()
- .filter(|e| e.0 == "hide")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_hide = param_hide.and_then(|param_hide| param_hide.parse().ok());
-
- Box::new({
- {
- {
- Box::new(
- api_impl.get_webcapture_revision(
- param_rev_id,
- param_expand,
- param_hide,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_expand = query_params
+ .iter()
+ .filter(|e| e.0 == "expand")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_expand = match param_expand {
+ Some(param_expand) => {
+ let param_expand =
+ <String as std::str::FromStr>::from_str(&param_expand);
+ match param_expand {
+ Ok(param_expand) => Some(param_expand),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter expand - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter expand")),
+ }
+ }
+ None => None,
+ };
+ let param_hide = query_params
+ .iter()
+ .filter(|e| e.0 == "hide")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_hide = match param_hide {
+ Some(param_hide) => {
+ let param_hide = <String as std::str::FromStr>::from_str(&param_hide);
+ match param_hide {
+ Ok(param_hide) => Some(param_hide),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter hide - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter hide")),
+ }
+ }
+ None => None,
+ };
- match result {
- Ok(rsp) => match rsp {
- GetWebcaptureRevisionResponse::FoundEntityRevision
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ let result = api_impl
+ .get_webcapture_revision(param_rev_id, param_expand, param_hide, &context)
+ .await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetWebcaptureRevisionResponse::FoundEntityRevision(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_WEBCAPTURE_REVISION_FOUND_ENTITY_REVISION"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetWebcaptureRevisionResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetWebcaptureRevisionResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_WEBCAPTURE_REVISION_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetWebcaptureRevisionResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetWebcaptureRevisionResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_WEBCAPTURE_REVISION_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetWebcaptureRevisionResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetWebcaptureRevisionResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_WEBCAPTURE_REVISION_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // GetWork - GET /work/{ident}
- &hyper::Method::GET if path.matched(paths::ID_WORK_IDENT) => {
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params = paths::REGEX_WORK_IDENT.captures(&path).unwrap_or_else(|| {
- panic!(
- "Path {} matched RE WORK_IDENT in set but failed match against \"{}\"",
- path,
- paths::REGEX_WORK_IDENT.as_str()
- )
- });
-
- let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ Ok(response)
+ }
+
+ // GetWork - GET /work/{ident}
+ &hyper::Method::GET if path.matched(paths::ID_WORK_IDENT) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
+ paths::REGEX_WORK_IDENT
+ .captures(&path)
+ .unwrap_or_else(||
+ panic!("Path {} matched RE WORK_IDENT in set but failed match against \"{}\"", path, paths::REGEX_WORK_IDENT.as_str())
+ );
+
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
Ok(param_ident) => match param_ident.parse::<String>() {
Ok(param_ident) => param_ident,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
- let query_params =
- form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
- .collect::<Vec<_>>();
- let param_expand = query_params
- .iter()
- .filter(|e| e.0 == "expand")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_expand = param_expand.and_then(|param_expand| param_expand.parse().ok());
- let param_hide = query_params
- .iter()
- .filter(|e| e.0 == "hide")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_hide = param_hide.and_then(|param_hide| param_hide.parse().ok());
-
- Box::new({
- {
- {
- Box::new(
- api_impl.get_work(
- param_ident,
- param_expand,
- param_hide,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_expand = query_params
+ .iter()
+ .filter(|e| e.0 == "expand")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_expand = match param_expand {
+ Some(param_expand) => {
+ let param_expand =
+ <String as std::str::FromStr>::from_str(&param_expand);
+ match param_expand {
+ Ok(param_expand) => Some(param_expand),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter expand - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter expand")),
+ }
+ }
+ None => None,
+ };
+ let param_hide = query_params
+ .iter()
+ .filter(|e| e.0 == "hide")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_hide = match param_hide {
+ Some(param_hide) => {
+ let param_hide = <String as std::str::FromStr>::from_str(&param_hide);
+ match param_hide {
+ Ok(param_hide) => Some(param_hide),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter hide - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter hide")),
+ }
+ }
+ None => None,
+ };
- match result {
- Ok(rsp) => match rsp {
- GetWorkResponse::FoundEntity
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ let result = api_impl
+ .get_work(param_ident, param_expand, param_hide, &context)
+ .await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetWorkResponse::FoundEntity(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_WORK_FOUND_ENTITY"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetWorkResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetWorkResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_WORK_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetWorkResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetWorkResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_WORK_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetWorkResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetWorkResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_WORK_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // GetWorkEdit - GET /work/edit/{edit_id}
- &hyper::Method::GET if path.matched(paths::ID_WORK_EDIT_EDIT_ID) => {
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ Ok(response)
+ }
+
+ // GetWorkEdit - GET /work/edit/{edit_id}
+ &hyper::Method::GET if path.matched(paths::ID_WORK_EDIT_EDIT_ID) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_WORK_EDIT_EDIT_ID
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE WORK_EDIT_EDIT_ID in set but failed match against \"{}\"", path, paths::REGEX_WORK_EDIT_EDIT_ID.as_str())
);
- let param_edit_id = match percent_encoding::percent_decode(path_params["edit_id"].as_bytes()).decode_utf8() {
+ let param_edit_id = match percent_encoding::percent_decode(path_params["edit_id"].as_bytes()).decode_utf8() {
Ok(param_edit_id) => match param_edit_id.parse::<String>() {
Ok(param_edit_id) => param_edit_id,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter edit_id: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["edit_id"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- Box::new({
- {
- {
- Box::new(
- api_impl.get_work_edit(
- param_edit_id,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ let result = api_impl.get_work_edit(param_edit_id, &context).await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
- match result {
- Ok(rsp) => match rsp {
- GetWorkEditResponse::FoundEdit
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ match result {
+ Ok(rsp) => match rsp {
+ GetWorkEditResponse::FoundEdit(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_WORK_EDIT_FOUND_EDIT"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetWorkEditResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetWorkEditResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_WORK_EDIT_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetWorkEditResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetWorkEditResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_WORK_EDIT_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetWorkEditResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetWorkEditResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_WORK_EDIT_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // GetWorkHistory - GET /work/{ident}/history
- &hyper::Method::GET if path.matched(paths::ID_WORK_IDENT_HISTORY) => {
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ Ok(response)
+ }
+
+ // GetWorkHistory - GET /work/{ident}/history
+ &hyper::Method::GET if path.matched(paths::ID_WORK_IDENT_HISTORY) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_WORK_IDENT_HISTORY
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE WORK_IDENT_HISTORY in set but failed match against \"{}\"", path, paths::REGEX_WORK_IDENT_HISTORY.as_str())
);
- let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
Ok(param_ident) => match param_ident.parse::<String>() {
Ok(param_ident) => param_ident,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
- let query_params =
- form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
- .collect::<Vec<_>>();
- let param_limit = query_params
- .iter()
- .filter(|e| e.0 == "limit")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_limit = param_limit.and_then(|param_limit| param_limit.parse().ok());
-
- Box::new({
- {
- {
- Box::new(
- api_impl.get_work_history(
- param_ident,
- param_limit,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_limit = query_params
+ .iter()
+ .filter(|e| e.0 == "limit")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_limit = match param_limit {
+ Some(param_limit) => {
+ let param_limit = <i64 as std::str::FromStr>::from_str(&param_limit);
+ match param_limit {
+ Ok(param_limit) => Some(param_limit),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter limit - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter limit")),
+ }
+ }
+ None => None,
+ };
- match result {
- Ok(rsp) => match rsp {
- GetWorkHistoryResponse::FoundEntityHistory
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ let result = api_impl
+ .get_work_history(param_ident, param_limit, &context)
+ .await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetWorkHistoryResponse::FoundEntityHistory(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_WORK_HISTORY_FOUND_ENTITY_HISTORY"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetWorkHistoryResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetWorkHistoryResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_WORK_HISTORY_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetWorkHistoryResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetWorkHistoryResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_WORK_HISTORY_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetWorkHistoryResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetWorkHistoryResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_WORK_HISTORY_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // GetWorkRedirects - GET /work/{ident}/redirects
- &hyper::Method::GET if path.matched(paths::ID_WORK_IDENT_REDIRECTS) => {
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ Ok(response)
+ }
+
+ // GetWorkRedirects - GET /work/{ident}/redirects
+ &hyper::Method::GET if path.matched(paths::ID_WORK_IDENT_REDIRECTS) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_WORK_IDENT_REDIRECTS
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE WORK_IDENT_REDIRECTS in set but failed match against \"{}\"", path, paths::REGEX_WORK_IDENT_REDIRECTS.as_str())
);
- let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
Ok(param_ident) => match param_ident.parse::<String>() {
Ok(param_ident) => param_ident,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- Box::new({
- {
- {
- Box::new(
- api_impl.get_work_redirects(
- param_ident,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ let result = api_impl.get_work_redirects(param_ident, &context).await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
- match result {
- Ok(rsp) => match rsp {
- GetWorkRedirectsResponse::FoundEntityRedirects
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ match result {
+ Ok(rsp) => match rsp {
+ GetWorkRedirectsResponse::FoundEntityRedirects(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_WORK_REDIRECTS_FOUND_ENTITY_REDIRECTS"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetWorkRedirectsResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetWorkRedirectsResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_WORK_REDIRECTS_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetWorkRedirectsResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetWorkRedirectsResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_WORK_REDIRECTS_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetWorkRedirectsResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetWorkRedirectsResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_WORK_REDIRECTS_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // GetWorkReleases - GET /work/{ident}/releases
- &hyper::Method::GET if path.matched(paths::ID_WORK_IDENT_RELEASES) => {
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ Ok(response)
+ }
+
+ // GetWorkReleases - GET /work/{ident}/releases
+ &hyper::Method::GET if path.matched(paths::ID_WORK_IDENT_RELEASES) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_WORK_IDENT_RELEASES
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE WORK_IDENT_RELEASES in set but failed match against \"{}\"", path, paths::REGEX_WORK_IDENT_RELEASES.as_str())
);
- let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
Ok(param_ident) => match param_ident.parse::<String>() {
Ok(param_ident) => param_ident,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
- let query_params =
- form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
- .collect::<Vec<_>>();
- let param_hide = query_params
- .iter()
- .filter(|e| e.0 == "hide")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_hide = param_hide.and_then(|param_hide| param_hide.parse().ok());
-
- Box::new({
- {
- {
- Box::new(
- api_impl.get_work_releases(
- param_ident,
- param_hide,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_hide = query_params
+ .iter()
+ .filter(|e| e.0 == "hide")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_hide = match param_hide {
+ Some(param_hide) => {
+ let param_hide = <String as std::str::FromStr>::from_str(&param_hide);
+ match param_hide {
+ Ok(param_hide) => Some(param_hide),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter hide - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter hide")),
+ }
+ }
+ None => None,
+ };
- match result {
- Ok(rsp) => match rsp {
- GetWorkReleasesResponse::Found
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ let result = api_impl
+ .get_work_releases(param_ident, param_hide, &context)
+ .await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetWorkReleasesResponse::Found(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_WORK_RELEASES_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetWorkReleasesResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetWorkReleasesResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_WORK_RELEASES_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetWorkReleasesResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetWorkReleasesResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_WORK_RELEASES_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetWorkReleasesResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetWorkReleasesResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_WORK_RELEASES_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // GetWorkRevision - GET /work/rev/{rev_id}
- &hyper::Method::GET if path.matched(paths::ID_WORK_REV_REV_ID) => {
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ Ok(response)
+ }
+
+ // GetWorkRevision - GET /work/rev/{rev_id}
+ &hyper::Method::GET if path.matched(paths::ID_WORK_REV_REV_ID) => {
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_WORK_REV_REV_ID
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE WORK_REV_REV_ID in set but failed match against \"{}\"", path, paths::REGEX_WORK_REV_REV_ID.as_str())
);
- let param_rev_id = match percent_encoding::percent_decode(path_params["rev_id"].as_bytes()).decode_utf8() {
+ let param_rev_id = match percent_encoding::percent_decode(path_params["rev_id"].as_bytes()).decode_utf8() {
Ok(param_rev_id) => match param_rev_id.parse::<String>() {
Ok(param_rev_id) => param_rev_id,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter rev_id: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["rev_id"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
- let query_params =
- form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
- .collect::<Vec<_>>();
- let param_expand = query_params
- .iter()
- .filter(|e| e.0 == "expand")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_expand = param_expand.and_then(|param_expand| param_expand.parse().ok());
- let param_hide = query_params
- .iter()
- .filter(|e| e.0 == "hide")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_hide = param_hide.and_then(|param_hide| param_hide.parse().ok());
-
- Box::new({
- {
- {
- Box::new(
- api_impl.get_work_revision(
- param_rev_id,
- param_expand,
- param_hide,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_expand = query_params
+ .iter()
+ .filter(|e| e.0 == "expand")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_expand = match param_expand {
+ Some(param_expand) => {
+ let param_expand =
+ <String as std::str::FromStr>::from_str(&param_expand);
+ match param_expand {
+ Ok(param_expand) => Some(param_expand),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter expand - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter expand")),
+ }
+ }
+ None => None,
+ };
+ let param_hide = query_params
+ .iter()
+ .filter(|e| e.0 == "hide")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_hide = match param_hide {
+ Some(param_hide) => {
+ let param_hide = <String as std::str::FromStr>::from_str(&param_hide);
+ match param_hide {
+ Ok(param_hide) => Some(param_hide),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter hide - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter hide")),
+ }
+ }
+ None => None,
+ };
- match result {
- Ok(rsp) => match rsp {
- GetWorkRevisionResponse::FoundEntityRevision
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ let result = api_impl
+ .get_work_revision(param_rev_id, param_expand, param_hide, &context)
+ .await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
+
+ match result {
+ Ok(rsp) => match rsp {
+ GetWorkRevisionResponse::FoundEntityRevision(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_WORK_REVISION_FOUND_ENTITY_REVISION"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetWorkRevisionResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetWorkRevisionResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_WORK_REVISION_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetWorkRevisionResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetWorkRevisionResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_WORK_REVISION_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- GetWorkRevisionResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ GetWorkRevisionResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_WORK_REVISION_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // LookupContainer - GET /container/lookup
- &hyper::Method::GET if path.matched(paths::ID_CONTAINER_LOOKUP) => {
- // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
- let query_params =
- form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
- .collect::<Vec<_>>();
- let param_issnl = query_params
- .iter()
- .filter(|e| e.0 == "issnl")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_issnl = param_issnl.and_then(|param_issnl| param_issnl.parse().ok());
- let param_wikidata_qid = query_params
- .iter()
- .filter(|e| e.0 == "wikidata_qid")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_wikidata_qid = param_wikidata_qid
- .and_then(|param_wikidata_qid| param_wikidata_qid.parse().ok());
- let param_expand = query_params
- .iter()
- .filter(|e| e.0 == "expand")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_expand = param_expand.and_then(|param_expand| param_expand.parse().ok());
- let param_hide = query_params
- .iter()
- .filter(|e| e.0 == "hide")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_hide = param_hide.and_then(|param_hide| param_hide.parse().ok());
-
- Box::new({
- {
- {
- Box::new(
- api_impl.lookup_container(
- param_issnl,
- param_wikidata_qid,
- param_expand,
- param_hide,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ Ok(response)
+ }
- match result {
- Ok(rsp) => match rsp {
- LookupContainerResponse::FoundEntity
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ // LookupContainer - GET /container/lookup
+ &hyper::Method::GET if path.matched(paths::ID_CONTAINER_LOOKUP) => {
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_issnl = query_params
+ .iter()
+ .filter(|e| e.0 == "issnl")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_issnl = match param_issnl {
+ Some(param_issnl) => {
+ let param_issnl = <String as std::str::FromStr>::from_str(&param_issnl);
+ match param_issnl {
+ Ok(param_issnl) => Some(param_issnl),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter issnl - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter issnl")),
+ }
+ }
+ None => None,
+ };
+ let param_wikidata_qid = query_params
+ .iter()
+ .filter(|e| e.0 == "wikidata_qid")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_wikidata_qid = match param_wikidata_qid {
+ Some(param_wikidata_qid) => {
+ let param_wikidata_qid =
+ <String as std::str::FromStr>::from_str(&param_wikidata_qid);
+ match param_wikidata_qid {
+ Ok(param_wikidata_qid) => Some(param_wikidata_qid),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter wikidata_qid - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter wikidata_qid")),
+ }
+ }
+ None => None,
+ };
+ let param_expand = query_params
+ .iter()
+ .filter(|e| e.0 == "expand")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_expand = match param_expand {
+ Some(param_expand) => {
+ let param_expand =
+ <String as std::str::FromStr>::from_str(&param_expand);
+ match param_expand {
+ Ok(param_expand) => Some(param_expand),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter expand - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter expand")),
+ }
+ }
+ None => None,
+ };
+ let param_hide = query_params
+ .iter()
+ .filter(|e| e.0 == "hide")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_hide = match param_hide {
+ Some(param_hide) => {
+ let param_hide = <String as std::str::FromStr>::from_str(&param_hide);
+ match param_hide {
+ Ok(param_hide) => Some(param_hide),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter hide - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter hide")),
+ }
+ }
+ None => None,
+ };
+
+ let result = api_impl
+ .lookup_container(
+ param_issnl,
+ param_wikidata_qid,
+ param_expand,
+ param_hide,
+ &context,
+ )
+ .await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
+
+ match result {
+ Ok(rsp) => match rsp {
+ LookupContainerResponse::FoundEntity(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for LOOKUP_CONTAINER_FOUND_ENTITY"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- LookupContainerResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ LookupContainerResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for LOOKUP_CONTAINER_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- LookupContainerResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ LookupContainerResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for LOOKUP_CONTAINER_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- LookupContainerResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ LookupContainerResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for LOOKUP_CONTAINER_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // LookupCreator - GET /creator/lookup
- &hyper::Method::GET if path.matched(paths::ID_CREATOR_LOOKUP) => {
- // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
- let query_params =
- form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
- .collect::<Vec<_>>();
- let param_orcid = query_params
- .iter()
- .filter(|e| e.0 == "orcid")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_orcid = param_orcid.and_then(|param_orcid| param_orcid.parse().ok());
- let param_wikidata_qid = query_params
- .iter()
- .filter(|e| e.0 == "wikidata_qid")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_wikidata_qid = param_wikidata_qid
- .and_then(|param_wikidata_qid| param_wikidata_qid.parse().ok());
- let param_expand = query_params
- .iter()
- .filter(|e| e.0 == "expand")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_expand = param_expand.and_then(|param_expand| param_expand.parse().ok());
- let param_hide = query_params
- .iter()
- .filter(|e| e.0 == "hide")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_hide = param_hide.and_then(|param_hide| param_hide.parse().ok());
-
- Box::new({
- {
- {
- Box::new(
- api_impl.lookup_creator(
- param_orcid,
- param_wikidata_qid,
- param_expand,
- param_hide,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ Ok(response)
+ }
- match result {
- Ok(rsp) => match rsp {
- LookupCreatorResponse::FoundEntity
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ // LookupCreator - GET /creator/lookup
+ &hyper::Method::GET if path.matched(paths::ID_CREATOR_LOOKUP) => {
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_orcid = query_params
+ .iter()
+ .filter(|e| e.0 == "orcid")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_orcid = match param_orcid {
+ Some(param_orcid) => {
+ let param_orcid = <String as std::str::FromStr>::from_str(&param_orcid);
+ match param_orcid {
+ Ok(param_orcid) => Some(param_orcid),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter orcid - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter orcid")),
+ }
+ }
+ None => None,
+ };
+ let param_wikidata_qid = query_params
+ .iter()
+ .filter(|e| e.0 == "wikidata_qid")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_wikidata_qid = match param_wikidata_qid {
+ Some(param_wikidata_qid) => {
+ let param_wikidata_qid =
+ <String as std::str::FromStr>::from_str(&param_wikidata_qid);
+ match param_wikidata_qid {
+ Ok(param_wikidata_qid) => Some(param_wikidata_qid),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter wikidata_qid - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter wikidata_qid")),
+ }
+ }
+ None => None,
+ };
+ let param_expand = query_params
+ .iter()
+ .filter(|e| e.0 == "expand")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_expand = match param_expand {
+ Some(param_expand) => {
+ let param_expand =
+ <String as std::str::FromStr>::from_str(&param_expand);
+ match param_expand {
+ Ok(param_expand) => Some(param_expand),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter expand - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter expand")),
+ }
+ }
+ None => None,
+ };
+ let param_hide = query_params
+ .iter()
+ .filter(|e| e.0 == "hide")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_hide = match param_hide {
+ Some(param_hide) => {
+ let param_hide = <String as std::str::FromStr>::from_str(&param_hide);
+ match param_hide {
+ Ok(param_hide) => Some(param_hide),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter hide - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter hide")),
+ }
+ }
+ None => None,
+ };
+
+ let result = api_impl
+ .lookup_creator(
+ param_orcid,
+ param_wikidata_qid,
+ param_expand,
+ param_hide,
+ &context,
+ )
+ .await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
+
+ match result {
+ Ok(rsp) => match rsp {
+ LookupCreatorResponse::FoundEntity(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for LOOKUP_CREATOR_FOUND_ENTITY"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- LookupCreatorResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ LookupCreatorResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for LOOKUP_CREATOR_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- LookupCreatorResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ LookupCreatorResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for LOOKUP_CREATOR_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- LookupCreatorResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ LookupCreatorResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for LOOKUP_CREATOR_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // LookupFile - GET /file/lookup
- &hyper::Method::GET if path.matched(paths::ID_FILE_LOOKUP) => {
- // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
- let query_params =
- form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
- .collect::<Vec<_>>();
- let param_md5 = query_params
- .iter()
- .filter(|e| e.0 == "md5")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_md5 = param_md5.and_then(|param_md5| param_md5.parse().ok());
- let param_sha1 = query_params
- .iter()
- .filter(|e| e.0 == "sha1")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_sha1 = param_sha1.and_then(|param_sha1| param_sha1.parse().ok());
- let param_sha256 = query_params
- .iter()
- .filter(|e| e.0 == "sha256")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_sha256 = param_sha256.and_then(|param_sha256| param_sha256.parse().ok());
- let param_expand = query_params
- .iter()
- .filter(|e| e.0 == "expand")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_expand = param_expand.and_then(|param_expand| param_expand.parse().ok());
- let param_hide = query_params
- .iter()
- .filter(|e| e.0 == "hide")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_hide = param_hide.and_then(|param_hide| param_hide.parse().ok());
-
- Box::new({
- {
- {
- Box::new(
- api_impl.lookup_file(
- param_md5,
- param_sha1,
- param_sha256,
- param_expand,
- param_hide,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ Ok(response)
+ }
- match result {
- Ok(rsp) => match rsp {
- LookupFileResponse::FoundEntity
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ // LookupFile - GET /file/lookup
+ &hyper::Method::GET if path.matched(paths::ID_FILE_LOOKUP) => {
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_md5 = query_params
+ .iter()
+ .filter(|e| e.0 == "md5")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_md5 = match param_md5 {
+ Some(param_md5) => {
+ let param_md5 = <String as std::str::FromStr>::from_str(&param_md5);
+ match param_md5 {
+ Ok(param_md5) => Some(param_md5),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter md5 - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter md5")),
+ }
+ }
+ None => None,
+ };
+ let param_sha1 = query_params
+ .iter()
+ .filter(|e| e.0 == "sha1")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_sha1 = match param_sha1 {
+ Some(param_sha1) => {
+ let param_sha1 = <String as std::str::FromStr>::from_str(&param_sha1);
+ match param_sha1 {
+ Ok(param_sha1) => Some(param_sha1),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter sha1 - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter sha1")),
+ }
+ }
+ None => None,
+ };
+ let param_sha256 = query_params
+ .iter()
+ .filter(|e| e.0 == "sha256")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_sha256 = match param_sha256 {
+ Some(param_sha256) => {
+ let param_sha256 =
+ <String as std::str::FromStr>::from_str(&param_sha256);
+ match param_sha256 {
+ Ok(param_sha256) => Some(param_sha256),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter sha256 - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter sha256")),
+ }
+ }
+ None => None,
+ };
+ let param_expand = query_params
+ .iter()
+ .filter(|e| e.0 == "expand")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_expand = match param_expand {
+ Some(param_expand) => {
+ let param_expand =
+ <String as std::str::FromStr>::from_str(&param_expand);
+ match param_expand {
+ Ok(param_expand) => Some(param_expand),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter expand - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter expand")),
+ }
+ }
+ None => None,
+ };
+ let param_hide = query_params
+ .iter()
+ .filter(|e| e.0 == "hide")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_hide = match param_hide {
+ Some(param_hide) => {
+ let param_hide = <String as std::str::FromStr>::from_str(&param_hide);
+ match param_hide {
+ Ok(param_hide) => Some(param_hide),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter hide - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter hide")),
+ }
+ }
+ None => None,
+ };
+
+ let result = api_impl
+ .lookup_file(
+ param_md5,
+ param_sha1,
+ param_sha256,
+ param_expand,
+ param_hide,
+ &context,
+ )
+ .await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
+
+ match result {
+ Ok(rsp) => match rsp {
+ LookupFileResponse::FoundEntity(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for LOOKUP_FILE_FOUND_ENTITY"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- LookupFileResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ LookupFileResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for LOOKUP_FILE_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- LookupFileResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ LookupFileResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for LOOKUP_FILE_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- LookupFileResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ LookupFileResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for LOOKUP_FILE_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // LookupRelease - GET /release/lookup
- &hyper::Method::GET if path.matched(paths::ID_RELEASE_LOOKUP) => {
- // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
- let query_params =
- form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
- .collect::<Vec<_>>();
- let param_doi = query_params
- .iter()
- .filter(|e| e.0 == "doi")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_doi = param_doi.and_then(|param_doi| param_doi.parse().ok());
- let param_wikidata_qid = query_params
- .iter()
- .filter(|e| e.0 == "wikidata_qid")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_wikidata_qid = param_wikidata_qid
- .and_then(|param_wikidata_qid| param_wikidata_qid.parse().ok());
- let param_isbn13 = query_params
- .iter()
- .filter(|e| e.0 == "isbn13")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_isbn13 = param_isbn13.and_then(|param_isbn13| param_isbn13.parse().ok());
- let param_pmid = query_params
- .iter()
- .filter(|e| e.0 == "pmid")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_pmid = param_pmid.and_then(|param_pmid| param_pmid.parse().ok());
- let param_pmcid = query_params
- .iter()
- .filter(|e| e.0 == "pmcid")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_pmcid = param_pmcid.and_then(|param_pmcid| param_pmcid.parse().ok());
- let param_core = query_params
- .iter()
- .filter(|e| e.0 == "core")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_core = param_core.and_then(|param_core| param_core.parse().ok());
- let param_arxiv = query_params
- .iter()
- .filter(|e| e.0 == "arxiv")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_arxiv = param_arxiv.and_then(|param_arxiv| param_arxiv.parse().ok());
- let param_jstor = query_params
- .iter()
- .filter(|e| e.0 == "jstor")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_jstor = param_jstor.and_then(|param_jstor| param_jstor.parse().ok());
- let param_ark = query_params
- .iter()
- .filter(|e| e.0 == "ark")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_ark = param_ark.and_then(|param_ark| param_ark.parse().ok());
- let param_mag = query_params
- .iter()
- .filter(|e| e.0 == "mag")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_mag = param_mag.and_then(|param_mag| param_mag.parse().ok());
- let param_expand = query_params
- .iter()
- .filter(|e| e.0 == "expand")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_expand = param_expand.and_then(|param_expand| param_expand.parse().ok());
- let param_hide = query_params
- .iter()
- .filter(|e| e.0 == "hide")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_hide = param_hide.and_then(|param_hide| param_hide.parse().ok());
-
- Box::new({
- {
- {
- Box::new(
- api_impl.lookup_release(
- param_doi,
- param_wikidata_qid,
- param_isbn13,
- param_pmid,
- param_pmcid,
- param_core,
- param_arxiv,
- param_jstor,
- param_ark,
- param_mag,
- param_expand,
- param_hide,
- &context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
- HeaderName::from_static("x-span-id"),
- HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
- .expect("Unable to create X-Span-ID header value"));
+ Ok(response)
+ }
- match result {
- Ok(rsp) => match rsp {
- LookupReleaseResponse::FoundEntity
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
- response.headers_mut().insert(
+ // LookupRelease - GET /release/lookup
+ &hyper::Method::GET if path.matched(paths::ID_RELEASE_LOOKUP) => {
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_doi = query_params
+ .iter()
+ .filter(|e| e.0 == "doi")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_doi = match param_doi {
+ Some(param_doi) => {
+ let param_doi = <String as std::str::FromStr>::from_str(&param_doi);
+ match param_doi {
+ Ok(param_doi) => Some(param_doi),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter doi - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter doi")),
+ }
+ }
+ None => None,
+ };
+ let param_wikidata_qid = query_params
+ .iter()
+ .filter(|e| e.0 == "wikidata_qid")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_wikidata_qid = match param_wikidata_qid {
+ Some(param_wikidata_qid) => {
+ let param_wikidata_qid =
+ <String as std::str::FromStr>::from_str(&param_wikidata_qid);
+ match param_wikidata_qid {
+ Ok(param_wikidata_qid) => Some(param_wikidata_qid),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter wikidata_qid - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter wikidata_qid")),
+ }
+ }
+ None => None,
+ };
+ let param_isbn13 = query_params
+ .iter()
+ .filter(|e| e.0 == "isbn13")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_isbn13 = match param_isbn13 {
+ Some(param_isbn13) => {
+ let param_isbn13 =
+ <String as std::str::FromStr>::from_str(&param_isbn13);
+ match param_isbn13 {
+ Ok(param_isbn13) => Some(param_isbn13),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter isbn13 - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter isbn13")),
+ }
+ }
+ None => None,
+ };
+ let param_pmid = query_params
+ .iter()
+ .filter(|e| e.0 == "pmid")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_pmid = match param_pmid {
+ Some(param_pmid) => {
+ let param_pmid = <String as std::str::FromStr>::from_str(&param_pmid);
+ match param_pmid {
+ Ok(param_pmid) => Some(param_pmid),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter pmid - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter pmid")),
+ }
+ }
+ None => None,
+ };
+ let param_pmcid = query_params
+ .iter()
+ .filter(|e| e.0 == "pmcid")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_pmcid = match param_pmcid {
+ Some(param_pmcid) => {
+ let param_pmcid = <String as std::str::FromStr>::from_str(&param_pmcid);
+ match param_pmcid {
+ Ok(param_pmcid) => Some(param_pmcid),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter pmcid - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter pmcid")),
+ }
+ }
+ None => None,
+ };
+ let param_core = query_params
+ .iter()
+ .filter(|e| e.0 == "core")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_core = match param_core {
+ Some(param_core) => {
+ let param_core = <String as std::str::FromStr>::from_str(&param_core);
+ match param_core {
+ Ok(param_core) => Some(param_core),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter core - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter core")),
+ }
+ }
+ None => None,
+ };
+ let param_arxiv = query_params
+ .iter()
+ .filter(|e| e.0 == "arxiv")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_arxiv = match param_arxiv {
+ Some(param_arxiv) => {
+ let param_arxiv = <String as std::str::FromStr>::from_str(&param_arxiv);
+ match param_arxiv {
+ Ok(param_arxiv) => Some(param_arxiv),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter arxiv - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter arxiv")),
+ }
+ }
+ None => None,
+ };
+ let param_jstor = query_params
+ .iter()
+ .filter(|e| e.0 == "jstor")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_jstor = match param_jstor {
+ Some(param_jstor) => {
+ let param_jstor = <String as std::str::FromStr>::from_str(&param_jstor);
+ match param_jstor {
+ Ok(param_jstor) => Some(param_jstor),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter jstor - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter jstor")),
+ }
+ }
+ None => None,
+ };
+ let param_ark = query_params
+ .iter()
+ .filter(|e| e.0 == "ark")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_ark = match param_ark {
+ Some(param_ark) => {
+ let param_ark = <String as std::str::FromStr>::from_str(&param_ark);
+ match param_ark {
+ Ok(param_ark) => Some(param_ark),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter ark - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter ark")),
+ }
+ }
+ None => None,
+ };
+ let param_mag = query_params
+ .iter()
+ .filter(|e| e.0 == "mag")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_mag = match param_mag {
+ Some(param_mag) => {
+ let param_mag = <String as std::str::FromStr>::from_str(&param_mag);
+ match param_mag {
+ Ok(param_mag) => Some(param_mag),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter mag - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter mag")),
+ }
+ }
+ None => None,
+ };
+ let param_doaj = query_params
+ .iter()
+ .filter(|e| e.0 == "doaj")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_doaj = match param_doaj {
+ Some(param_doaj) => {
+ let param_doaj = <String as std::str::FromStr>::from_str(&param_doaj);
+ match param_doaj {
+ Ok(param_doaj) => Some(param_doaj),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter doaj - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter doaj")),
+ }
+ }
+ None => None,
+ };
+ let param_dblp = query_params
+ .iter()
+ .filter(|e| e.0 == "dblp")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_dblp = match param_dblp {
+ Some(param_dblp) => {
+ let param_dblp = <String as std::str::FromStr>::from_str(&param_dblp);
+ match param_dblp {
+ Ok(param_dblp) => Some(param_dblp),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter dblp - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter dblp")),
+ }
+ }
+ None => None,
+ };
+ let param_oai = query_params
+ .iter()
+ .filter(|e| e.0 == "oai")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_oai = match param_oai {
+ Some(param_oai) => {
+ let param_oai = <String as std::str::FromStr>::from_str(&param_oai);
+ match param_oai {
+ Ok(param_oai) => Some(param_oai),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter oai - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter oai")),
+ }
+ }
+ None => None,
+ };
+ let param_expand = query_params
+ .iter()
+ .filter(|e| e.0 == "expand")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_expand = match param_expand {
+ Some(param_expand) => {
+ let param_expand =
+ <String as std::str::FromStr>::from_str(&param_expand);
+ match param_expand {
+ Ok(param_expand) => Some(param_expand),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter expand - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter expand")),
+ }
+ }
+ None => None,
+ };
+ let param_hide = query_params
+ .iter()
+ .filter(|e| e.0 == "hide")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_hide = match param_hide {
+ Some(param_hide) => {
+ let param_hide = <String as std::str::FromStr>::from_str(&param_hide);
+ match param_hide {
+ Ok(param_hide) => Some(param_hide),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter hide - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter hide")),
+ }
+ }
+ None => None,
+ };
+
+ let result = api_impl
+ .lookup_release(
+ param_doi,
+ param_wikidata_qid,
+ param_isbn13,
+ param_pmid,
+ param_pmcid,
+ param_core,
+ param_arxiv,
+ param_jstor,
+ param_ark,
+ param_mag,
+ param_doaj,
+ param_dblp,
+ param_oai,
+ param_expand,
+ param_hide,
+ &context,
+ )
+ .await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
+ HeaderName::from_static("x-span-id"),
+ HeaderValue::from_str(
+ (&context as &dyn Has<XSpanIdString>)
+ .get()
+ .0
+ .clone()
+ .to_string()
+ .as_str(),
+ )
+ .expect("Unable to create X-Span-ID header value"),
+ );
+
+ match result {
+ Ok(rsp) => match rsp {
+ LookupReleaseResponse::FoundEntity(body) => {
+ *response.status_mut() = StatusCode::from_u16(200)
+ .expect("Unable to turn 200 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for LOOKUP_RELEASE_FOUND_ENTITY"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- LookupReleaseResponse::BadRequest
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(400).expect("Unable to turn 400 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ LookupReleaseResponse::BadRequest(body) => {
+ *response.status_mut() = StatusCode::from_u16(400)
+ .expect("Unable to turn 400 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for LOOKUP_RELEASE_BAD_REQUEST"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- LookupReleaseResponse::NotFound
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ LookupReleaseResponse::NotFound(body) => {
+ *response.status_mut() = StatusCode::from_u16(404)
+ .expect("Unable to turn 404 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for LOOKUP_RELEASE_NOT_FOUND"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- LookupReleaseResponse::GenericError
- (body)
- => {
- *response.status_mut() = StatusCode::from_u16(500).expect("Unable to turn 500 into a StatusCode");
- response.headers_mut().insert(
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ LookupReleaseResponse::GenericError(body) => {
+ *response.status_mut() = StatusCode::from_u16(500)
+ .expect("Unable to turn 500 into a StatusCode");
+ response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for LOOKUP_RELEASE_GENERIC_ERROR"));
- let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
- *response.body_mut() = Body::from(body);
- },
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
- *response.body_mut() = Body::from("An internal error occurred");
- },
- }
-
- future::ok(response)
- }
- ))
+ let body = serde_json::to_string(&body)
+ .expect("impossible to fail to serialize");
+ *response.body_mut() = Body::from(body);
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
+ *response.body_mut() = Body::from("An internal error occurred");
}
}
- }) as Self::Future
- }
- // UpdateContainer - PUT /editgroup/{editgroup_id}/container/{ident}
- &hyper::Method::PUT
- if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_CONTAINER_IDENT) =>
- {
+ Ok(response)
+ }
+
+ // UpdateContainer - PUT /editgroup/{editgroup_id}/container/{ident}
+ &hyper::Method::PUT
+ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_CONTAINER_IDENT) =>
{
- let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
- &Some(ref authorization) => authorization,
- &None => {
- return Box::new(future::ok(
- Response::builder()
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>)
+ .get()
+ {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Ok(Response::builder()
.status(StatusCode::FORBIDDEN)
.body(Body::from("Unauthenticated"))
- .expect("Unable to create Authentication Forbidden response"),
- ))
- }
- };
- }
+ .expect("Unable to create Authentication Forbidden response"))
+ }
+ };
+ }
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_EDITGROUP_EDITGROUP_ID_CONTAINER_IDENT
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID_CONTAINER_IDENT in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID_CONTAINER_IDENT.as_str())
);
- let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
Ok(param_editgroup_id) => param_editgroup_id,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
Ok(param_ident) => match param_ident.parse::<String>() {
Ok(param_ident) => param_ident,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- // Body parameters (note that non-required body parameters will ignore garbage
- // values, rather than causing a 400 response). Produce warning header and logs for
- // any unused fields.
- Box::new(body.concat2()
- .then(move |result| -> Self::Future {
- match result {
+ // Body parameters (note that non-required body parameters will ignore garbage
+ // values, rather than causing a 400 response). Produce warning header and logs for
+ // any unused fields.
+ let result = body.to_raw().await;
+ match result {
Ok(body) => {
let mut unused_elements = Vec::new();
let param_container_entity: Option<models::ContainerEntity> = if !body.is_empty() {
@@ -12695,31 +13540,30 @@ where
unused_elements.push(path.to_string());
}) {
Ok(param_container_entity) => param_container_entity,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse body parameter ContainerEntity - doesn't match schema: {}", e)))
- .expect("Unable to create Bad Request response for invalid body parameter ContainerEntity due to schema"))),
+ .expect("Unable to create Bad Request response for invalid body parameter ContainerEntity due to schema")),
}
} else {
None
};
let param_container_entity = match param_container_entity {
Some(param_container_entity) => param_container_entity,
- None => return Box::new(future::ok(Response::builder()
+ None => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from("Missing required body parameter ContainerEntity"))
- .expect("Unable to create Bad Request response for missing body parameter ContainerEntity"))),
+ .expect("Unable to create Bad Request response for missing body parameter ContainerEntity")),
};
- Box::new(
- api_impl.update_container(
+ let result = api_impl.update_container(
param_editgroup_id,
param_ident,
param_container_entity,
&context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
+ ).await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
HeaderName::from_static("x-span-id"),
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
.expect("Unable to create X-Span-ID header value"));
@@ -12761,21 +13605,23 @@ where
www_authenticate
}
=> {
+ if let Some(www_authenticate) = www_authenticate {
let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
Ok(val) => val,
Err(e) => {
- return future::ok(Response::builder()
+ return Ok(Response::builder()
.status(StatusCode::INTERNAL_SERVER_ERROR)
.body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
.expect("Unable to create Internal Server Error for invalid response header"))
}
};
- *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
response.headers_mut().insert(
HeaderName::from_static("www_authenticate"),
www_authenticate
);
+ }
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
@@ -12825,78 +13671,75 @@ where
},
}
- future::ok(response)
- }
- ))
+ Ok(response)
},
- Err(e) => Box::new(future::ok(Response::builder()
+ Err(e) => Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't read body parameter ContainerEntity: {}", e)))
- .expect("Unable to create Bad Request response due to unable to read body parameter ContainerEntity"))),
+ .expect("Unable to create Bad Request response due to unable to read body parameter ContainerEntity")),
}
- })
- ) as Self::Future
- }
+ }
- // UpdateCreator - PUT /editgroup/{editgroup_id}/creator/{ident}
- &hyper::Method::PUT if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_CREATOR_IDENT) => {
+ // UpdateCreator - PUT /editgroup/{editgroup_id}/creator/{ident}
+ &hyper::Method::PUT
+ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_CREATOR_IDENT) =>
{
- let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
- &Some(ref authorization) => authorization,
- &None => {
- return Box::new(future::ok(
- Response::builder()
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>)
+ .get()
+ {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Ok(Response::builder()
.status(StatusCode::FORBIDDEN)
.body(Body::from("Unauthenticated"))
- .expect("Unable to create Authentication Forbidden response"),
- ))
- }
- };
- }
+ .expect("Unable to create Authentication Forbidden response"))
+ }
+ };
+ }
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_EDITGROUP_EDITGROUP_ID_CREATOR_IDENT
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID_CREATOR_IDENT in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID_CREATOR_IDENT.as_str())
);
- let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
Ok(param_editgroup_id) => param_editgroup_id,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
Ok(param_ident) => match param_ident.parse::<String>() {
Ok(param_ident) => param_ident,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- // Body parameters (note that non-required body parameters will ignore garbage
- // values, rather than causing a 400 response). Produce warning header and logs for
- // any unused fields.
- Box::new(body.concat2()
- .then(move |result| -> Self::Future {
- match result {
+ // Body parameters (note that non-required body parameters will ignore garbage
+ // values, rather than causing a 400 response). Produce warning header and logs for
+ // any unused fields.
+ let result = body.to_raw().await;
+ match result {
Ok(body) => {
let mut unused_elements = Vec::new();
let param_creator_entity: Option<models::CreatorEntity> = if !body.is_empty() {
@@ -12906,31 +13749,30 @@ where
unused_elements.push(path.to_string());
}) {
Ok(param_creator_entity) => param_creator_entity,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse body parameter CreatorEntity - doesn't match schema: {}", e)))
- .expect("Unable to create Bad Request response for invalid body parameter CreatorEntity due to schema"))),
+ .expect("Unable to create Bad Request response for invalid body parameter CreatorEntity due to schema")),
}
} else {
None
};
let param_creator_entity = match param_creator_entity {
Some(param_creator_entity) => param_creator_entity,
- None => return Box::new(future::ok(Response::builder()
+ None => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from("Missing required body parameter CreatorEntity"))
- .expect("Unable to create Bad Request response for missing body parameter CreatorEntity"))),
+ .expect("Unable to create Bad Request response for missing body parameter CreatorEntity")),
};
- Box::new(
- api_impl.update_creator(
+ let result = api_impl.update_creator(
param_editgroup_id,
param_ident,
param_creator_entity,
&context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
+ ).await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
HeaderName::from_static("x-span-id"),
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
.expect("Unable to create X-Span-ID header value"));
@@ -12972,21 +13814,23 @@ where
www_authenticate
}
=> {
+ if let Some(www_authenticate) = www_authenticate {
let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
Ok(val) => val,
Err(e) => {
- return future::ok(Response::builder()
+ return Ok(Response::builder()
.status(StatusCode::INTERNAL_SERVER_ERROR)
.body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
.expect("Unable to create Internal Server Error for invalid response header"))
}
};
- *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
response.headers_mut().insert(
HeaderName::from_static("www_authenticate"),
www_authenticate
);
+ }
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
@@ -13036,75 +13880,82 @@ where
},
}
- future::ok(response)
- }
- ))
+ Ok(response)
},
- Err(e) => Box::new(future::ok(Response::builder()
+ Err(e) => Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't read body parameter CreatorEntity: {}", e)))
- .expect("Unable to create Bad Request response due to unable to read body parameter CreatorEntity"))),
+ .expect("Unable to create Bad Request response due to unable to read body parameter CreatorEntity")),
}
- })
- ) as Self::Future
- }
+ }
- // UpdateEditgroup - PUT /editgroup/{editgroup_id}
- &hyper::Method::PUT if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID) => {
- {
- let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
- &Some(ref authorization) => authorization,
- &None => {
- return Box::new(future::ok(
- Response::builder()
+ // UpdateEditgroup - PUT /editgroup/{editgroup_id}
+ &hyper::Method::PUT if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID) => {
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>)
+ .get()
+ {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Ok(Response::builder()
.status(StatusCode::FORBIDDEN)
.body(Body::from("Unauthenticated"))
- .expect("Unable to create Authentication Forbidden response"),
- ))
- }
- };
- }
+ .expect("Unable to create Authentication Forbidden response"))
+ }
+ };
+ }
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_EDITGROUP_EDITGROUP_ID
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID.as_str())
);
- let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
Ok(param_editgroup_id) => param_editgroup_id,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
- let query_params =
- form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
- .collect::<Vec<_>>();
- let param_submit = query_params
- .iter()
- .filter(|e| e.0 == "submit")
- .map(|e| e.1.to_owned())
- .nth(0);
- let param_submit = param_submit.and_then(|param_submit| param_submit.parse().ok());
-
- // Body parameters (note that non-required body parameters will ignore garbage
- // values, rather than causing a 400 response). Produce warning header and logs for
- // any unused fields.
- Box::new(body.concat2()
- .then(move |result| -> Self::Future {
- match result {
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params =
+ form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())
+ .collect::<Vec<_>>();
+ let param_submit = query_params
+ .iter()
+ .filter(|e| e.0 == "submit")
+ .map(|e| e.1.to_owned())
+ .nth(0);
+ let param_submit = match param_submit {
+ Some(param_submit) => {
+ let param_submit = <bool as std::str::FromStr>::from_str(&param_submit);
+ match param_submit {
+ Ok(param_submit) => Some(param_submit),
+ Err(e) => return Ok(Response::builder()
+ .status(StatusCode::BAD_REQUEST)
+ .body(Body::from(format!("Couldn't parse query parameter submit - doesn't match schema: {}", e)))
+ .expect("Unable to create Bad Request response for invalid query parameter submit")),
+ }
+ }
+ None => None,
+ };
+
+ // Body parameters (note that non-required body parameters will ignore garbage
+ // values, rather than causing a 400 response). Produce warning header and logs for
+ // any unused fields.
+ let result = body.to_raw().await;
+ match result {
Ok(body) => {
let mut unused_elements = Vec::new();
let param_editgroup: Option<models::Editgroup> = if !body.is_empty() {
@@ -13114,31 +13965,30 @@ where
unused_elements.push(path.to_string());
}) {
Ok(param_editgroup) => param_editgroup,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse body parameter Editgroup - doesn't match schema: {}", e)))
- .expect("Unable to create Bad Request response for invalid body parameter Editgroup due to schema"))),
+ .expect("Unable to create Bad Request response for invalid body parameter Editgroup due to schema")),
}
} else {
None
};
let param_editgroup = match param_editgroup {
Some(param_editgroup) => param_editgroup,
- None => return Box::new(future::ok(Response::builder()
+ None => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from("Missing required body parameter Editgroup"))
- .expect("Unable to create Bad Request response for missing body parameter Editgroup"))),
+ .expect("Unable to create Bad Request response for missing body parameter Editgroup")),
};
- Box::new(
- api_impl.update_editgroup(
+ let result = api_impl.update_editgroup(
param_editgroup_id,
param_editgroup,
param_submit,
&context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
+ ).await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
HeaderName::from_static("x-span-id"),
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
.expect("Unable to create X-Span-ID header value"));
@@ -13180,21 +14030,23 @@ where
www_authenticate
}
=> {
+ if let Some(www_authenticate) = www_authenticate {
let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
Ok(val) => val,
Err(e) => {
- return future::ok(Response::builder()
+ return Ok(Response::builder()
.status(StatusCode::INTERNAL_SERVER_ERROR)
.body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
.expect("Unable to create Internal Server Error for invalid response header"))
}
};
- *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
response.headers_mut().insert(
HeaderName::from_static("www_authenticate"),
www_authenticate
);
+ }
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
@@ -13244,64 +14096,59 @@ where
},
}
- future::ok(response)
- }
- ))
+ Ok(response)
},
- Err(e) => Box::new(future::ok(Response::builder()
+ Err(e) => Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't read body parameter Editgroup: {}", e)))
- .expect("Unable to create Bad Request response due to unable to read body parameter Editgroup"))),
+ .expect("Unable to create Bad Request response due to unable to read body parameter Editgroup")),
}
- })
- ) as Self::Future
- }
+ }
- // UpdateEditor - PUT /editor/{editor_id}
- &hyper::Method::PUT if path.matched(paths::ID_EDITOR_EDITOR_ID) => {
- {
- let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
- &Some(ref authorization) => authorization,
- &None => {
- return Box::new(future::ok(
- Response::builder()
+ // UpdateEditor - PUT /editor/{editor_id}
+ &hyper::Method::PUT if path.matched(paths::ID_EDITOR_EDITOR_ID) => {
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>)
+ .get()
+ {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Ok(Response::builder()
.status(StatusCode::FORBIDDEN)
.body(Body::from("Unauthenticated"))
- .expect("Unable to create Authentication Forbidden response"),
- ))
- }
- };
- }
+ .expect("Unable to create Authentication Forbidden response"))
+ }
+ };
+ }
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_EDITOR_EDITOR_ID
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE EDITOR_EDITOR_ID in set but failed match against \"{}\"", path, paths::REGEX_EDITOR_EDITOR_ID.as_str())
);
- let param_editor_id = match percent_encoding::percent_decode(path_params["editor_id"].as_bytes()).decode_utf8() {
+ let param_editor_id = match percent_encoding::percent_decode(path_params["editor_id"].as_bytes()).decode_utf8() {
Ok(param_editor_id) => match param_editor_id.parse::<String>() {
Ok(param_editor_id) => param_editor_id,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter editor_id: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editor_id"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- // Body parameters (note that non-required body parameters will ignore garbage
- // values, rather than causing a 400 response). Produce warning header and logs for
- // any unused fields.
- Box::new(body.concat2()
- .then(move |result| -> Self::Future {
- match result {
+ // Body parameters (note that non-required body parameters will ignore garbage
+ // values, rather than causing a 400 response). Produce warning header and logs for
+ // any unused fields.
+ let result = body.to_raw().await;
+ match result {
Ok(body) => {
let mut unused_elements = Vec::new();
let param_editor: Option<models::Editor> = if !body.is_empty() {
@@ -13311,30 +14158,29 @@ where
unused_elements.push(path.to_string());
}) {
Ok(param_editor) => param_editor,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse body parameter Editor - doesn't match schema: {}", e)))
- .expect("Unable to create Bad Request response for invalid body parameter Editor due to schema"))),
+ .expect("Unable to create Bad Request response for invalid body parameter Editor due to schema")),
}
} else {
None
};
let param_editor = match param_editor {
Some(param_editor) => param_editor,
- None => return Box::new(future::ok(Response::builder()
+ None => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from("Missing required body parameter Editor"))
- .expect("Unable to create Bad Request response for missing body parameter Editor"))),
+ .expect("Unable to create Bad Request response for missing body parameter Editor")),
};
- Box::new(
- api_impl.update_editor(
+ let result = api_impl.update_editor(
param_editor_id,
param_editor,
&context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
+ ).await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
HeaderName::from_static("x-span-id"),
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
.expect("Unable to create X-Span-ID header value"));
@@ -13376,21 +14222,23 @@ where
www_authenticate
}
=> {
+ if let Some(www_authenticate) = www_authenticate {
let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
Ok(val) => val,
Err(e) => {
- return future::ok(Response::builder()
+ return Ok(Response::builder()
.status(StatusCode::INTERNAL_SERVER_ERROR)
.body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
.expect("Unable to create Internal Server Error for invalid response header"))
}
};
- *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
response.headers_mut().insert(
HeaderName::from_static("www_authenticate"),
www_authenticate
);
+ }
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
@@ -13440,78 +14288,75 @@ where
},
}
- future::ok(response)
- }
- ))
+ Ok(response)
},
- Err(e) => Box::new(future::ok(Response::builder()
+ Err(e) => Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't read body parameter Editor: {}", e)))
- .expect("Unable to create Bad Request response due to unable to read body parameter Editor"))),
+ .expect("Unable to create Bad Request response due to unable to read body parameter Editor")),
}
- })
- ) as Self::Future
- }
+ }
- // UpdateFile - PUT /editgroup/{editgroup_id}/file/{ident}
- &hyper::Method::PUT if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_FILE_IDENT) => {
+ // UpdateFile - PUT /editgroup/{editgroup_id}/file/{ident}
+ &hyper::Method::PUT
+ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_FILE_IDENT) =>
{
- let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
- &Some(ref authorization) => authorization,
- &None => {
- return Box::new(future::ok(
- Response::builder()
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>)
+ .get()
+ {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Ok(Response::builder()
.status(StatusCode::FORBIDDEN)
.body(Body::from("Unauthenticated"))
- .expect("Unable to create Authentication Forbidden response"),
- ))
- }
- };
- }
+ .expect("Unable to create Authentication Forbidden response"))
+ }
+ };
+ }
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_EDITGROUP_EDITGROUP_ID_FILE_IDENT
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID_FILE_IDENT in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID_FILE_IDENT.as_str())
);
- let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
Ok(param_editgroup_id) => param_editgroup_id,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
Ok(param_ident) => match param_ident.parse::<String>() {
Ok(param_ident) => param_ident,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- // Body parameters (note that non-required body parameters will ignore garbage
- // values, rather than causing a 400 response). Produce warning header and logs for
- // any unused fields.
- Box::new(body.concat2()
- .then(move |result| -> Self::Future {
- match result {
+ // Body parameters (note that non-required body parameters will ignore garbage
+ // values, rather than causing a 400 response). Produce warning header and logs for
+ // any unused fields.
+ let result = body.to_raw().await;
+ match result {
Ok(body) => {
let mut unused_elements = Vec::new();
let param_file_entity: Option<models::FileEntity> = if !body.is_empty() {
@@ -13521,31 +14366,30 @@ where
unused_elements.push(path.to_string());
}) {
Ok(param_file_entity) => param_file_entity,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse body parameter FileEntity - doesn't match schema: {}", e)))
- .expect("Unable to create Bad Request response for invalid body parameter FileEntity due to schema"))),
+ .expect("Unable to create Bad Request response for invalid body parameter FileEntity due to schema")),
}
} else {
None
};
let param_file_entity = match param_file_entity {
Some(param_file_entity) => param_file_entity,
- None => return Box::new(future::ok(Response::builder()
+ None => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from("Missing required body parameter FileEntity"))
- .expect("Unable to create Bad Request response for missing body parameter FileEntity"))),
+ .expect("Unable to create Bad Request response for missing body parameter FileEntity")),
};
- Box::new(
- api_impl.update_file(
+ let result = api_impl.update_file(
param_editgroup_id,
param_ident,
param_file_entity,
&context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
+ ).await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
HeaderName::from_static("x-span-id"),
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
.expect("Unable to create X-Span-ID header value"));
@@ -13587,21 +14431,23 @@ where
www_authenticate
}
=> {
+ if let Some(www_authenticate) = www_authenticate {
let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
Ok(val) => val,
Err(e) => {
- return future::ok(Response::builder()
+ return Ok(Response::builder()
.status(StatusCode::INTERNAL_SERVER_ERROR)
.body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
.expect("Unable to create Internal Server Error for invalid response header"))
}
};
- *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
response.headers_mut().insert(
HeaderName::from_static("www_authenticate"),
www_authenticate
);
+ }
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
@@ -13651,78 +14497,75 @@ where
},
}
- future::ok(response)
- }
- ))
+ Ok(response)
},
- Err(e) => Box::new(future::ok(Response::builder()
+ Err(e) => Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't read body parameter FileEntity: {}", e)))
- .expect("Unable to create Bad Request response due to unable to read body parameter FileEntity"))),
+ .expect("Unable to create Bad Request response due to unable to read body parameter FileEntity")),
}
- })
- ) as Self::Future
- }
+ }
- // UpdateFileset - PUT /editgroup/{editgroup_id}/fileset/{ident}
- &hyper::Method::PUT if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_FILESET_IDENT) => {
+ // UpdateFileset - PUT /editgroup/{editgroup_id}/fileset/{ident}
+ &hyper::Method::PUT
+ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_FILESET_IDENT) =>
{
- let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
- &Some(ref authorization) => authorization,
- &None => {
- return Box::new(future::ok(
- Response::builder()
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>)
+ .get()
+ {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Ok(Response::builder()
.status(StatusCode::FORBIDDEN)
.body(Body::from("Unauthenticated"))
- .expect("Unable to create Authentication Forbidden response"),
- ))
- }
- };
- }
+ .expect("Unable to create Authentication Forbidden response"))
+ }
+ };
+ }
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_EDITGROUP_EDITGROUP_ID_FILESET_IDENT
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID_FILESET_IDENT in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID_FILESET_IDENT.as_str())
);
- let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
Ok(param_editgroup_id) => param_editgroup_id,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
Ok(param_ident) => match param_ident.parse::<String>() {
Ok(param_ident) => param_ident,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- // Body parameters (note that non-required body parameters will ignore garbage
- // values, rather than causing a 400 response). Produce warning header and logs for
- // any unused fields.
- Box::new(body.concat2()
- .then(move |result| -> Self::Future {
- match result {
+ // Body parameters (note that non-required body parameters will ignore garbage
+ // values, rather than causing a 400 response). Produce warning header and logs for
+ // any unused fields.
+ let result = body.to_raw().await;
+ match result {
Ok(body) => {
let mut unused_elements = Vec::new();
let param_fileset_entity: Option<models::FilesetEntity> = if !body.is_empty() {
@@ -13732,31 +14575,30 @@ where
unused_elements.push(path.to_string());
}) {
Ok(param_fileset_entity) => param_fileset_entity,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse body parameter FilesetEntity - doesn't match schema: {}", e)))
- .expect("Unable to create Bad Request response for invalid body parameter FilesetEntity due to schema"))),
+ .expect("Unable to create Bad Request response for invalid body parameter FilesetEntity due to schema")),
}
} else {
None
};
let param_fileset_entity = match param_fileset_entity {
Some(param_fileset_entity) => param_fileset_entity,
- None => return Box::new(future::ok(Response::builder()
+ None => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from("Missing required body parameter FilesetEntity"))
- .expect("Unable to create Bad Request response for missing body parameter FilesetEntity"))),
+ .expect("Unable to create Bad Request response for missing body parameter FilesetEntity")),
};
- Box::new(
- api_impl.update_fileset(
+ let result = api_impl.update_fileset(
param_editgroup_id,
param_ident,
param_fileset_entity,
&context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
+ ).await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
HeaderName::from_static("x-span-id"),
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
.expect("Unable to create X-Span-ID header value"));
@@ -13798,21 +14640,23 @@ where
www_authenticate
}
=> {
+ if let Some(www_authenticate) = www_authenticate {
let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
Ok(val) => val,
Err(e) => {
- return future::ok(Response::builder()
+ return Ok(Response::builder()
.status(StatusCode::INTERNAL_SERVER_ERROR)
.body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
.expect("Unable to create Internal Server Error for invalid response header"))
}
};
- *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
response.headers_mut().insert(
HeaderName::from_static("www_authenticate"),
www_authenticate
);
+ }
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
@@ -13862,78 +14706,75 @@ where
},
}
- future::ok(response)
- }
- ))
+ Ok(response)
},
- Err(e) => Box::new(future::ok(Response::builder()
+ Err(e) => Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't read body parameter FilesetEntity: {}", e)))
- .expect("Unable to create Bad Request response due to unable to read body parameter FilesetEntity"))),
+ .expect("Unable to create Bad Request response due to unable to read body parameter FilesetEntity")),
}
- })
- ) as Self::Future
- }
+ }
- // UpdateRelease - PUT /editgroup/{editgroup_id}/release/{ident}
- &hyper::Method::PUT if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_RELEASE_IDENT) => {
+ // UpdateRelease - PUT /editgroup/{editgroup_id}/release/{ident}
+ &hyper::Method::PUT
+ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_RELEASE_IDENT) =>
{
- let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
- &Some(ref authorization) => authorization,
- &None => {
- return Box::new(future::ok(
- Response::builder()
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>)
+ .get()
+ {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Ok(Response::builder()
.status(StatusCode::FORBIDDEN)
.body(Body::from("Unauthenticated"))
- .expect("Unable to create Authentication Forbidden response"),
- ))
- }
- };
- }
+ .expect("Unable to create Authentication Forbidden response"))
+ }
+ };
+ }
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_EDITGROUP_EDITGROUP_ID_RELEASE_IDENT
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID_RELEASE_IDENT in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID_RELEASE_IDENT.as_str())
);
- let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
Ok(param_editgroup_id) => param_editgroup_id,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
Ok(param_ident) => match param_ident.parse::<String>() {
Ok(param_ident) => param_ident,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- // Body parameters (note that non-required body parameters will ignore garbage
- // values, rather than causing a 400 response). Produce warning header and logs for
- // any unused fields.
- Box::new(body.concat2()
- .then(move |result| -> Self::Future {
- match result {
+ // Body parameters (note that non-required body parameters will ignore garbage
+ // values, rather than causing a 400 response). Produce warning header and logs for
+ // any unused fields.
+ let result = body.to_raw().await;
+ match result {
Ok(body) => {
let mut unused_elements = Vec::new();
let param_release_entity: Option<models::ReleaseEntity> = if !body.is_empty() {
@@ -13943,31 +14784,30 @@ where
unused_elements.push(path.to_string());
}) {
Ok(param_release_entity) => param_release_entity,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse body parameter ReleaseEntity - doesn't match schema: {}", e)))
- .expect("Unable to create Bad Request response for invalid body parameter ReleaseEntity due to schema"))),
+ .expect("Unable to create Bad Request response for invalid body parameter ReleaseEntity due to schema")),
}
} else {
None
};
let param_release_entity = match param_release_entity {
Some(param_release_entity) => param_release_entity,
- None => return Box::new(future::ok(Response::builder()
+ None => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from("Missing required body parameter ReleaseEntity"))
- .expect("Unable to create Bad Request response for missing body parameter ReleaseEntity"))),
+ .expect("Unable to create Bad Request response for missing body parameter ReleaseEntity")),
};
- Box::new(
- api_impl.update_release(
+ let result = api_impl.update_release(
param_editgroup_id,
param_ident,
param_release_entity,
&context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
+ ).await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
HeaderName::from_static("x-span-id"),
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
.expect("Unable to create X-Span-ID header value"));
@@ -14009,21 +14849,23 @@ where
www_authenticate
}
=> {
+ if let Some(www_authenticate) = www_authenticate {
let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
Ok(val) => val,
Err(e) => {
- return future::ok(Response::builder()
+ return Ok(Response::builder()
.status(StatusCode::INTERNAL_SERVER_ERROR)
.body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
.expect("Unable to create Internal Server Error for invalid response header"))
}
};
- *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
response.headers_mut().insert(
HeaderName::from_static("www_authenticate"),
www_authenticate
);
+ }
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
@@ -14073,80 +14915,75 @@ where
},
}
- future::ok(response)
- }
- ))
+ Ok(response)
},
- Err(e) => Box::new(future::ok(Response::builder()
+ Err(e) => Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't read body parameter ReleaseEntity: {}", e)))
- .expect("Unable to create Bad Request response due to unable to read body parameter ReleaseEntity"))),
+ .expect("Unable to create Bad Request response due to unable to read body parameter ReleaseEntity")),
}
- })
- ) as Self::Future
- }
+ }
- // UpdateWebcapture - PUT /editgroup/{editgroup_id}/webcapture/{ident}
- &hyper::Method::PUT
- if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_WEBCAPTURE_IDENT) =>
- {
+ // UpdateWebcapture - PUT /editgroup/{editgroup_id}/webcapture/{ident}
+ &hyper::Method::PUT
+ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_WEBCAPTURE_IDENT) =>
{
- let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
- &Some(ref authorization) => authorization,
- &None => {
- return Box::new(future::ok(
- Response::builder()
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>)
+ .get()
+ {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Ok(Response::builder()
.status(StatusCode::FORBIDDEN)
.body(Body::from("Unauthenticated"))
- .expect("Unable to create Authentication Forbidden response"),
- ))
- }
- };
- }
+ .expect("Unable to create Authentication Forbidden response"))
+ }
+ };
+ }
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_EDITGROUP_EDITGROUP_ID_WEBCAPTURE_IDENT
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID_WEBCAPTURE_IDENT in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID_WEBCAPTURE_IDENT.as_str())
);
- let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
Ok(param_editgroup_id) => param_editgroup_id,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
Ok(param_ident) => match param_ident.parse::<String>() {
Ok(param_ident) => param_ident,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- // Body parameters (note that non-required body parameters will ignore garbage
- // values, rather than causing a 400 response). Produce warning header and logs for
- // any unused fields.
- Box::new(body.concat2()
- .then(move |result| -> Self::Future {
- match result {
+ // Body parameters (note that non-required body parameters will ignore garbage
+ // values, rather than causing a 400 response). Produce warning header and logs for
+ // any unused fields.
+ let result = body.to_raw().await;
+ match result {
Ok(body) => {
let mut unused_elements = Vec::new();
let param_webcapture_entity: Option<models::WebcaptureEntity> = if !body.is_empty() {
@@ -14156,31 +14993,30 @@ where
unused_elements.push(path.to_string());
}) {
Ok(param_webcapture_entity) => param_webcapture_entity,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse body parameter WebcaptureEntity - doesn't match schema: {}", e)))
- .expect("Unable to create Bad Request response for invalid body parameter WebcaptureEntity due to schema"))),
+ .expect("Unable to create Bad Request response for invalid body parameter WebcaptureEntity due to schema")),
}
} else {
None
};
let param_webcapture_entity = match param_webcapture_entity {
Some(param_webcapture_entity) => param_webcapture_entity,
- None => return Box::new(future::ok(Response::builder()
+ None => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from("Missing required body parameter WebcaptureEntity"))
- .expect("Unable to create Bad Request response for missing body parameter WebcaptureEntity"))),
+ .expect("Unable to create Bad Request response for missing body parameter WebcaptureEntity")),
};
- Box::new(
- api_impl.update_webcapture(
+ let result = api_impl.update_webcapture(
param_editgroup_id,
param_ident,
param_webcapture_entity,
&context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
+ ).await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
HeaderName::from_static("x-span-id"),
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
.expect("Unable to create X-Span-ID header value"));
@@ -14222,21 +15058,23 @@ where
www_authenticate
}
=> {
+ if let Some(www_authenticate) = www_authenticate {
let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
Ok(val) => val,
Err(e) => {
- return future::ok(Response::builder()
+ return Ok(Response::builder()
.status(StatusCode::INTERNAL_SERVER_ERROR)
.body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
.expect("Unable to create Internal Server Error for invalid response header"))
}
};
- *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
response.headers_mut().insert(
HeaderName::from_static("www_authenticate"),
www_authenticate
);
+ }
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
@@ -14286,78 +15124,75 @@ where
},
}
- future::ok(response)
- }
- ))
+ Ok(response)
},
- Err(e) => Box::new(future::ok(Response::builder()
+ Err(e) => Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't read body parameter WebcaptureEntity: {}", e)))
- .expect("Unable to create Bad Request response due to unable to read body parameter WebcaptureEntity"))),
+ .expect("Unable to create Bad Request response due to unable to read body parameter WebcaptureEntity")),
}
- })
- ) as Self::Future
- }
+ }
- // UpdateWork - PUT /editgroup/{editgroup_id}/work/{ident}
- &hyper::Method::PUT if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_WORK_IDENT) => {
+ // UpdateWork - PUT /editgroup/{editgroup_id}/work/{ident}
+ &hyper::Method::PUT
+ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_WORK_IDENT) =>
{
- let authorization = match (&context as &dyn Has<Option<Authorization>>).get() {
- &Some(ref authorization) => authorization,
- &None => {
- return Box::new(future::ok(
- Response::builder()
+ {
+ let authorization = match (&context as &dyn Has<Option<Authorization>>)
+ .get()
+ {
+ &Some(ref authorization) => authorization,
+ &None => {
+ return Ok(Response::builder()
.status(StatusCode::FORBIDDEN)
.body(Body::from("Unauthenticated"))
- .expect("Unable to create Authentication Forbidden response"),
- ))
- }
- };
- }
+ .expect("Unable to create Authentication Forbidden response"))
+ }
+ };
+ }
- // Path parameters
- let path: &str = &uri.path().to_string();
- let path_params =
+ // Path parameters
+ let path: &str = &uri.path().to_string();
+ let path_params =
paths::REGEX_EDITGROUP_EDITGROUP_ID_WORK_IDENT
.captures(&path)
.unwrap_or_else(||
panic!("Path {} matched RE EDITGROUP_EDITGROUP_ID_WORK_IDENT in set but failed match against \"{}\"", path, paths::REGEX_EDITGROUP_EDITGROUP_ID_WORK_IDENT.as_str())
);
- let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
+ let param_editgroup_id = match percent_encoding::percent_decode(path_params["editgroup_id"].as_bytes()).decode_utf8() {
Ok(param_editgroup_id) => match param_editgroup_id.parse::<String>() {
Ok(param_editgroup_id) => param_editgroup_id,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter editgroup_id: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["editgroup_id"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
+ let param_ident = match percent_encoding::percent_decode(path_params["ident"].as_bytes()).decode_utf8() {
Ok(param_ident) => match param_ident.parse::<String>() {
Ok(param_ident) => param_ident,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse path parameter ident: {}", e)))
- .expect("Unable to create Bad Request response for invalid path parameter"))),
+ .expect("Unable to create Bad Request response for invalid path parameter")),
},
- Err(_) => return Box::new(future::ok(Response::builder()
+ Err(_) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["ident"])))
- .expect("Unable to create Bad Request response for invalid percent decode")))
+ .expect("Unable to create Bad Request response for invalid percent decode"))
};
- // Body parameters (note that non-required body parameters will ignore garbage
- // values, rather than causing a 400 response). Produce warning header and logs for
- // any unused fields.
- Box::new(body.concat2()
- .then(move |result| -> Self::Future {
- match result {
+ // Body parameters (note that non-required body parameters will ignore garbage
+ // values, rather than causing a 400 response). Produce warning header and logs for
+ // any unused fields.
+ let result = body.to_raw().await;
+ match result {
Ok(body) => {
let mut unused_elements = Vec::new();
let param_work_entity: Option<models::WorkEntity> = if !body.is_empty() {
@@ -14367,31 +15202,30 @@ where
unused_elements.push(path.to_string());
}) {
Ok(param_work_entity) => param_work_entity,
- Err(e) => return Box::new(future::ok(Response::builder()
+ Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse body parameter WorkEntity - doesn't match schema: {}", e)))
- .expect("Unable to create Bad Request response for invalid body parameter WorkEntity due to schema"))),
+ .expect("Unable to create Bad Request response for invalid body parameter WorkEntity due to schema")),
}
} else {
None
};
let param_work_entity = match param_work_entity {
Some(param_work_entity) => param_work_entity,
- None => return Box::new(future::ok(Response::builder()
+ None => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from("Missing required body parameter WorkEntity"))
- .expect("Unable to create Bad Request response for missing body parameter WorkEntity"))),
+ .expect("Unable to create Bad Request response for missing body parameter WorkEntity")),
};
- Box::new(
- api_impl.update_work(
+ let result = api_impl.update_work(
param_editgroup_id,
param_ident,
param_work_entity,
&context
- ).then(move |result| {
- let mut response = Response::new(Body::empty());
- response.headers_mut().insert(
+ ).await;
+ let mut response = Response::new(Body::empty());
+ response.headers_mut().insert(
HeaderName::from_static("x-span-id"),
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
.expect("Unable to create X-Span-ID header value"));
@@ -14433,21 +15267,23 @@ where
www_authenticate
}
=> {
+ if let Some(www_authenticate) = www_authenticate {
let www_authenticate = match header::IntoHeaderValue(www_authenticate).try_into() {
Ok(val) => val,
Err(e) => {
- return future::ok(Response::builder()
+ return Ok(Response::builder()
.status(StatusCode::INTERNAL_SERVER_ERROR)
.body(Body::from(format!("An internal server error occurred handling www_authenticate header - {}", e)))
.expect("Unable to create Internal Server Error for invalid response header"))
}
};
- *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
response.headers_mut().insert(
HeaderName::from_static("www_authenticate"),
www_authenticate
);
+ }
+ *response.status_mut() = StatusCode::from_u16(401).expect("Unable to turn 401 into a StatusCode");
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("application/json")
@@ -14497,148 +15333,146 @@ where
},
}
- future::ok(response)
- }
- ))
+ Ok(response)
},
- Err(e) => Box::new(future::ok(Response::builder()
+ Err(e) => Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't read body parameter WorkEntity: {}", e)))
- .expect("Unable to create Bad Request response due to unable to read body parameter WorkEntity"))),
+ .expect("Unable to create Bad Request response due to unable to read body parameter WorkEntity")),
}
- })
- ) as Self::Future
- }
+ }
- _ if path.matched(paths::ID_AUTH_CHECK) => method_not_allowed(),
- _ if path.matched(paths::ID_AUTH_OIDC) => method_not_allowed(),
- _ if path.matched(paths::ID_AUTH_TOKEN_EDITOR_ID) => method_not_allowed(),
- _ if path.matched(paths::ID_CHANGELOG) => method_not_allowed(),
- _ if path.matched(paths::ID_CHANGELOG_INDEX) => method_not_allowed(),
- _ if path.matched(paths::ID_CONTAINER_EDIT_EDIT_ID) => method_not_allowed(),
- _ if path.matched(paths::ID_CONTAINER_LOOKUP) => method_not_allowed(),
- _ if path.matched(paths::ID_CONTAINER_REV_REV_ID) => method_not_allowed(),
- _ if path.matched(paths::ID_CONTAINER_IDENT) => method_not_allowed(),
- _ if path.matched(paths::ID_CONTAINER_IDENT_HISTORY) => method_not_allowed(),
- _ if path.matched(paths::ID_CONTAINER_IDENT_REDIRECTS) => method_not_allowed(),
- _ if path.matched(paths::ID_CREATOR_EDIT_EDIT_ID) => method_not_allowed(),
- _ if path.matched(paths::ID_CREATOR_LOOKUP) => method_not_allowed(),
- _ if path.matched(paths::ID_CREATOR_REV_REV_ID) => method_not_allowed(),
- _ if path.matched(paths::ID_CREATOR_IDENT) => method_not_allowed(),
- _ if path.matched(paths::ID_CREATOR_IDENT_HISTORY) => method_not_allowed(),
- _ if path.matched(paths::ID_CREATOR_IDENT_REDIRECTS) => method_not_allowed(),
- _ if path.matched(paths::ID_CREATOR_IDENT_RELEASES) => method_not_allowed(),
- _ if path.matched(paths::ID_EDITGROUP) => method_not_allowed(),
- _ if path.matched(paths::ID_EDITGROUP_AUTO_CONTAINER_BATCH) => method_not_allowed(),
- _ if path.matched(paths::ID_EDITGROUP_AUTO_CREATOR_BATCH) => method_not_allowed(),
- _ if path.matched(paths::ID_EDITGROUP_AUTO_FILE_BATCH) => method_not_allowed(),
- _ if path.matched(paths::ID_EDITGROUP_AUTO_FILESET_BATCH) => method_not_allowed(),
- _ if path.matched(paths::ID_EDITGROUP_AUTO_RELEASE_BATCH) => method_not_allowed(),
- _ if path.matched(paths::ID_EDITGROUP_AUTO_WEBCAPTURE_BATCH) => method_not_allowed(),
- _ if path.matched(paths::ID_EDITGROUP_AUTO_WORK_BATCH) => method_not_allowed(),
- _ if path.matched(paths::ID_EDITGROUP_REVIEWABLE) => method_not_allowed(),
- _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID) => method_not_allowed(),
- _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_ACCEPT) => method_not_allowed(),
- _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_ANNOTATION) => method_not_allowed(),
- _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_ANNOTATIONS) => method_not_allowed(),
- _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_CONTAINER) => method_not_allowed(),
- _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_CONTAINER_EDIT_EDIT_ID) => {
- method_not_allowed()
- }
- _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_CONTAINER_IDENT) => {
- method_not_allowed()
- }
- _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_CREATOR) => method_not_allowed(),
- _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_CREATOR_EDIT_EDIT_ID) => {
- method_not_allowed()
- }
- _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_CREATOR_IDENT) => {
- method_not_allowed()
- }
- _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_FILE) => method_not_allowed(),
- _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_FILE_EDIT_EDIT_ID) => {
- method_not_allowed()
- }
- _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_FILE_IDENT) => method_not_allowed(),
- _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_FILESET) => method_not_allowed(),
- _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_FILESET_EDIT_EDIT_ID) => {
- method_not_allowed()
- }
- _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_FILESET_IDENT) => {
- method_not_allowed()
- }
- _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_RELEASE) => method_not_allowed(),
- _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_RELEASE_EDIT_EDIT_ID) => {
- method_not_allowed()
- }
- _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_RELEASE_IDENT) => {
- method_not_allowed()
- }
- _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_WEBCAPTURE) => method_not_allowed(),
- _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_WEBCAPTURE_EDIT_EDIT_ID) => {
- method_not_allowed()
- }
- _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_WEBCAPTURE_IDENT) => {
- method_not_allowed()
- }
- _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_WORK) => method_not_allowed(),
- _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_WORK_EDIT_EDIT_ID) => {
- method_not_allowed()
- }
- _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_WORK_IDENT) => method_not_allowed(),
- _ if path.matched(paths::ID_EDITOR_EDITOR_ID) => method_not_allowed(),
- _ if path.matched(paths::ID_EDITOR_EDITOR_ID_ANNOTATIONS) => method_not_allowed(),
- _ if path.matched(paths::ID_EDITOR_EDITOR_ID_EDITGROUPS) => method_not_allowed(),
- _ if path.matched(paths::ID_FILE_EDIT_EDIT_ID) => method_not_allowed(),
- _ if path.matched(paths::ID_FILE_LOOKUP) => method_not_allowed(),
- _ if path.matched(paths::ID_FILE_REV_REV_ID) => method_not_allowed(),
- _ if path.matched(paths::ID_FILE_IDENT) => method_not_allowed(),
- _ if path.matched(paths::ID_FILE_IDENT_HISTORY) => method_not_allowed(),
- _ if path.matched(paths::ID_FILE_IDENT_REDIRECTS) => method_not_allowed(),
- _ if path.matched(paths::ID_FILESET_EDIT_EDIT_ID) => method_not_allowed(),
- _ if path.matched(paths::ID_FILESET_REV_REV_ID) => method_not_allowed(),
- _ if path.matched(paths::ID_FILESET_IDENT) => method_not_allowed(),
- _ if path.matched(paths::ID_FILESET_IDENT_HISTORY) => method_not_allowed(),
- _ if path.matched(paths::ID_FILESET_IDENT_REDIRECTS) => method_not_allowed(),
- _ if path.matched(paths::ID_RELEASE_EDIT_EDIT_ID) => method_not_allowed(),
- _ if path.matched(paths::ID_RELEASE_LOOKUP) => method_not_allowed(),
- _ if path.matched(paths::ID_RELEASE_REV_REV_ID) => method_not_allowed(),
- _ if path.matched(paths::ID_RELEASE_IDENT) => method_not_allowed(),
- _ if path.matched(paths::ID_RELEASE_IDENT_FILES) => method_not_allowed(),
- _ if path.matched(paths::ID_RELEASE_IDENT_FILESETS) => method_not_allowed(),
- _ if path.matched(paths::ID_RELEASE_IDENT_HISTORY) => method_not_allowed(),
- _ if path.matched(paths::ID_RELEASE_IDENT_REDIRECTS) => method_not_allowed(),
- _ if path.matched(paths::ID_RELEASE_IDENT_WEBCAPTURES) => method_not_allowed(),
- _ if path.matched(paths::ID_WEBCAPTURE_EDIT_EDIT_ID) => method_not_allowed(),
- _ if path.matched(paths::ID_WEBCAPTURE_REV_REV_ID) => method_not_allowed(),
- _ if path.matched(paths::ID_WEBCAPTURE_IDENT) => method_not_allowed(),
- _ if path.matched(paths::ID_WEBCAPTURE_IDENT_HISTORY) => method_not_allowed(),
- _ if path.matched(paths::ID_WEBCAPTURE_IDENT_REDIRECTS) => method_not_allowed(),
- _ if path.matched(paths::ID_WORK_EDIT_EDIT_ID) => method_not_allowed(),
- _ if path.matched(paths::ID_WORK_REV_REV_ID) => method_not_allowed(),
- _ if path.matched(paths::ID_WORK_IDENT) => method_not_allowed(),
- _ if path.matched(paths::ID_WORK_IDENT_HISTORY) => method_not_allowed(),
- _ if path.matched(paths::ID_WORK_IDENT_REDIRECTS) => method_not_allowed(),
- _ if path.matched(paths::ID_WORK_IDENT_RELEASES) => method_not_allowed(),
- _ => Box::new(future::ok(
- Response::builder()
+ _ if path.matched(paths::ID_AUTH_CHECK) => method_not_allowed(),
+ _ if path.matched(paths::ID_AUTH_OIDC) => method_not_allowed(),
+ _ if path.matched(paths::ID_AUTH_TOKEN_EDITOR_ID) => method_not_allowed(),
+ _ if path.matched(paths::ID_CHANGELOG) => method_not_allowed(),
+ _ if path.matched(paths::ID_CHANGELOG_INDEX) => method_not_allowed(),
+ _ if path.matched(paths::ID_CONTAINER_EDIT_EDIT_ID) => method_not_allowed(),
+ _ if path.matched(paths::ID_CONTAINER_LOOKUP) => method_not_allowed(),
+ _ if path.matched(paths::ID_CONTAINER_REV_REV_ID) => method_not_allowed(),
+ _ if path.matched(paths::ID_CONTAINER_IDENT) => method_not_allowed(),
+ _ if path.matched(paths::ID_CONTAINER_IDENT_HISTORY) => method_not_allowed(),
+ _ if path.matched(paths::ID_CONTAINER_IDENT_REDIRECTS) => method_not_allowed(),
+ _ if path.matched(paths::ID_CREATOR_EDIT_EDIT_ID) => method_not_allowed(),
+ _ if path.matched(paths::ID_CREATOR_LOOKUP) => method_not_allowed(),
+ _ if path.matched(paths::ID_CREATOR_REV_REV_ID) => method_not_allowed(),
+ _ if path.matched(paths::ID_CREATOR_IDENT) => method_not_allowed(),
+ _ if path.matched(paths::ID_CREATOR_IDENT_HISTORY) => method_not_allowed(),
+ _ if path.matched(paths::ID_CREATOR_IDENT_REDIRECTS) => method_not_allowed(),
+ _ if path.matched(paths::ID_CREATOR_IDENT_RELEASES) => method_not_allowed(),
+ _ if path.matched(paths::ID_EDITGROUP) => method_not_allowed(),
+ _ if path.matched(paths::ID_EDITGROUP_AUTO_CONTAINER_BATCH) => method_not_allowed(),
+ _ if path.matched(paths::ID_EDITGROUP_AUTO_CREATOR_BATCH) => method_not_allowed(),
+ _ if path.matched(paths::ID_EDITGROUP_AUTO_FILE_BATCH) => method_not_allowed(),
+ _ if path.matched(paths::ID_EDITGROUP_AUTO_FILESET_BATCH) => method_not_allowed(),
+ _ if path.matched(paths::ID_EDITGROUP_AUTO_RELEASE_BATCH) => method_not_allowed(),
+ _ if path.matched(paths::ID_EDITGROUP_AUTO_WEBCAPTURE_BATCH) => {
+ method_not_allowed()
+ }
+ _ if path.matched(paths::ID_EDITGROUP_AUTO_WORK_BATCH) => method_not_allowed(),
+ _ if path.matched(paths::ID_EDITGROUP_REVIEWABLE) => method_not_allowed(),
+ _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID) => method_not_allowed(),
+ _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_ACCEPT) => method_not_allowed(),
+ _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_ANNOTATION) => {
+ method_not_allowed()
+ }
+ _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_ANNOTATIONS) => {
+ method_not_allowed()
+ }
+ _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_CONTAINER) => {
+ method_not_allowed()
+ }
+ _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_CONTAINER_EDIT_EDIT_ID) => {
+ method_not_allowed()
+ }
+ _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_CONTAINER_IDENT) => {
+ method_not_allowed()
+ }
+ _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_CREATOR) => method_not_allowed(),
+ _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_CREATOR_EDIT_EDIT_ID) => {
+ method_not_allowed()
+ }
+ _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_CREATOR_IDENT) => {
+ method_not_allowed()
+ }
+ _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_FILE) => method_not_allowed(),
+ _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_FILE_EDIT_EDIT_ID) => {
+ method_not_allowed()
+ }
+ _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_FILE_IDENT) => {
+ method_not_allowed()
+ }
+ _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_FILESET) => method_not_allowed(),
+ _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_FILESET_EDIT_EDIT_ID) => {
+ method_not_allowed()
+ }
+ _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_FILESET_IDENT) => {
+ method_not_allowed()
+ }
+ _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_RELEASE) => method_not_allowed(),
+ _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_RELEASE_EDIT_EDIT_ID) => {
+ method_not_allowed()
+ }
+ _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_RELEASE_IDENT) => {
+ method_not_allowed()
+ }
+ _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_WEBCAPTURE) => {
+ method_not_allowed()
+ }
+ _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_WEBCAPTURE_EDIT_EDIT_ID) => {
+ method_not_allowed()
+ }
+ _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_WEBCAPTURE_IDENT) => {
+ method_not_allowed()
+ }
+ _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_WORK) => method_not_allowed(),
+ _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_WORK_EDIT_EDIT_ID) => {
+ method_not_allowed()
+ }
+ _ if path.matched(paths::ID_EDITGROUP_EDITGROUP_ID_WORK_IDENT) => {
+ method_not_allowed()
+ }
+ _ if path.matched(paths::ID_EDITOR_EDITOR_ID) => method_not_allowed(),
+ _ if path.matched(paths::ID_EDITOR_EDITOR_ID_ANNOTATIONS) => method_not_allowed(),
+ _ if path.matched(paths::ID_EDITOR_EDITOR_ID_EDITGROUPS) => method_not_allowed(),
+ _ if path.matched(paths::ID_FILE_EDIT_EDIT_ID) => method_not_allowed(),
+ _ if path.matched(paths::ID_FILE_LOOKUP) => method_not_allowed(),
+ _ if path.matched(paths::ID_FILE_REV_REV_ID) => method_not_allowed(),
+ _ if path.matched(paths::ID_FILE_IDENT) => method_not_allowed(),
+ _ if path.matched(paths::ID_FILE_IDENT_HISTORY) => method_not_allowed(),
+ _ if path.matched(paths::ID_FILE_IDENT_REDIRECTS) => method_not_allowed(),
+ _ if path.matched(paths::ID_FILESET_EDIT_EDIT_ID) => method_not_allowed(),
+ _ if path.matched(paths::ID_FILESET_REV_REV_ID) => method_not_allowed(),
+ _ if path.matched(paths::ID_FILESET_IDENT) => method_not_allowed(),
+ _ if path.matched(paths::ID_FILESET_IDENT_HISTORY) => method_not_allowed(),
+ _ if path.matched(paths::ID_FILESET_IDENT_REDIRECTS) => method_not_allowed(),
+ _ if path.matched(paths::ID_RELEASE_EDIT_EDIT_ID) => method_not_allowed(),
+ _ if path.matched(paths::ID_RELEASE_LOOKUP) => method_not_allowed(),
+ _ if path.matched(paths::ID_RELEASE_REV_REV_ID) => method_not_allowed(),
+ _ if path.matched(paths::ID_RELEASE_IDENT) => method_not_allowed(),
+ _ if path.matched(paths::ID_RELEASE_IDENT_FILES) => method_not_allowed(),
+ _ if path.matched(paths::ID_RELEASE_IDENT_FILESETS) => method_not_allowed(),
+ _ if path.matched(paths::ID_RELEASE_IDENT_HISTORY) => method_not_allowed(),
+ _ if path.matched(paths::ID_RELEASE_IDENT_REDIRECTS) => method_not_allowed(),
+ _ if path.matched(paths::ID_RELEASE_IDENT_WEBCAPTURES) => method_not_allowed(),
+ _ if path.matched(paths::ID_WEBCAPTURE_EDIT_EDIT_ID) => method_not_allowed(),
+ _ if path.matched(paths::ID_WEBCAPTURE_REV_REV_ID) => method_not_allowed(),
+ _ if path.matched(paths::ID_WEBCAPTURE_IDENT) => method_not_allowed(),
+ _ if path.matched(paths::ID_WEBCAPTURE_IDENT_HISTORY) => method_not_allowed(),
+ _ if path.matched(paths::ID_WEBCAPTURE_IDENT_REDIRECTS) => method_not_allowed(),
+ _ if path.matched(paths::ID_WORK_EDIT_EDIT_ID) => method_not_allowed(),
+ _ if path.matched(paths::ID_WORK_REV_REV_ID) => method_not_allowed(),
+ _ if path.matched(paths::ID_WORK_IDENT) => method_not_allowed(),
+ _ if path.matched(paths::ID_WORK_IDENT_HISTORY) => method_not_allowed(),
+ _ if path.matched(paths::ID_WORK_IDENT_REDIRECTS) => method_not_allowed(),
+ _ if path.matched(paths::ID_WORK_IDENT_RELEASES) => method_not_allowed(),
+ _ => Ok(Response::builder()
.status(StatusCode::NOT_FOUND)
.body(Body::empty())
- .expect("Unable to create Not Found response"),
- )) as Self::Future,
- }
- }
-}
-
-impl<T, C> Clone for Service<T, C>
-where
- T: Clone,
-{
- fn clone(&self) -> Self {
- Service {
- api_impl: self.api_impl.clone(),
- marker: self.marker.clone(),
+ .expect("Unable to create Not Found response")),
+ }
}
+ Box::pin(run(self.api_impl.clone(), req))
}
}