summaryrefslogtreecommitdiffstats
path: root/fatcat-openapi/examples/server/server.rs
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@archive.org>2022-08-11 19:39:44 -0700
committerBryan Newbold <bnewbold@archive.org>2022-08-11 19:39:47 -0700
commitf2179cc9071c4e95c307f7506e764ada9f484052 (patch)
treeb51d83986e91fddb2ad245003c87407ecbdcc563 /fatcat-openapi/examples/server/server.rs
parent7392e457fae4d9f7b3dfa79dccfdaf23d6f9d1a5 (diff)
downloadfatcat-cli-f2179cc9071c4e95c307f7506e764ada9f484052.tar.gz
fatcat-cli-f2179cc9071c4e95c307f7506e764ada9f484052.zip
re-codegen fatcat-openapi module
this includes manual reconsiliation of cargo deps (Cargo.toml)
Diffstat (limited to 'fatcat-openapi/examples/server/server.rs')
-rw-r--r--fatcat-openapi/examples/server/server.rs216
1 files changed, 104 insertions, 112 deletions
diff --git a/fatcat-openapi/examples/server/server.rs b/fatcat-openapi/examples/server/server.rs
index d09b080..c844de7 100644
--- a/fatcat-openapi/examples/server/server.rs
+++ b/fatcat-openapi/examples/server/server.rs
@@ -7,8 +7,6 @@ use futures::{future, Stream, StreamExt, TryFutureExt, TryStreamExt};
use hyper::server::conn::Http;
use hyper::service::Service;
use log::info;
-#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
-use openssl::ssl::SslAcceptorBuilder;
use std::future::Future;
use std::marker::PhantomData;
use std::net::SocketAddr;
@@ -20,7 +18,7 @@ use swagger::{Has, XSpanIdString};
use tokio::net::TcpListener;
#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
-use openssl::ssl::{SslAcceptor, SslFiletype, SslMethod};
+use openssl::ssl::{Ssl, SslAcceptor, SslAcceptorBuilder, SslFiletype, SslMethod};
use fatcat_openapi::models;
@@ -52,25 +50,21 @@ pub async fn create(addr: &str, https: bool) {
ssl.set_private_key_file("examples/server-key.pem", SslFiletype::PEM)
.expect("Failed to set private key");
ssl.set_certificate_chain_file("examples/server-chain.pem")
- .expect("Failed to set cerificate chain");
+ .expect("Failed to set certificate chain");
ssl.check_private_key()
.expect("Failed to check private key");
- let tls_acceptor = Arc::new(ssl.build());
- let mut tcp_listener = TcpListener::bind(&addr).await.unwrap();
- let mut incoming = tcp_listener.incoming();
+ let tls_acceptor = ssl.build();
+ let tcp_listener = TcpListener::bind(&addr).await.unwrap();
- while let (Some(tcp), rest) = incoming.into_future().await {
- if let Ok(tcp) = tcp {
+ loop {
+ if let Ok((tcp, _)) = tcp_listener.accept().await {
+ let ssl = Ssl::new(tls_acceptor.context()).unwrap();
let addr = tcp.peer_addr().expect("Unable to get remote address");
let service = service.call(addr);
- let tls_acceptor = Arc::clone(&tls_acceptor);
tokio::spawn(async move {
- let tls = tokio_openssl::accept(&*tls_acceptor, tcp)
- .await
- .map_err(|_| ())?;
-
+ let tls = tokio_openssl::SslStream::new(ssl, tcp).map_err(|_| ())?;
let service = service.await.map_err(|_| ())?;
Http::new()
@@ -79,8 +73,6 @@ pub async fn create(addr: &str, https: bool) {
.map_err(|_| ())
});
}
-
- incoming = rest;
}
}
} else {
@@ -156,7 +148,7 @@ where
editgroup_id,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn auth_check(
@@ -170,7 +162,7 @@ where
role,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn auth_oidc(
@@ -184,7 +176,7 @@ where
auth_oidc,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn create_auth_token(
@@ -200,7 +192,7 @@ where
duration_seconds,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn create_container(
@@ -216,7 +208,7 @@ where
container_entity,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn create_container_auto_batch(
@@ -230,7 +222,7 @@ where
container_auto_batch,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn create_creator(
@@ -246,7 +238,7 @@ where
creator_entity,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn create_creator_auto_batch(
@@ -260,7 +252,7 @@ where
creator_auto_batch,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn create_editgroup(
@@ -274,7 +266,7 @@ where
editgroup,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn create_editgroup_annotation(
@@ -290,7 +282,7 @@ where
editgroup_annotation,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn create_file(
@@ -306,7 +298,7 @@ where
file_entity,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn create_file_auto_batch(
@@ -320,7 +312,7 @@ where
file_auto_batch,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn create_fileset(
@@ -336,7 +328,7 @@ where
fileset_entity,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn create_fileset_auto_batch(
@@ -350,7 +342,7 @@ where
fileset_auto_batch,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn create_release(
@@ -366,7 +358,7 @@ where
release_entity,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn create_release_auto_batch(
@@ -380,7 +372,7 @@ where
release_auto_batch,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn create_webcapture(
@@ -396,7 +388,7 @@ where
webcapture_entity,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn create_webcapture_auto_batch(
@@ -410,7 +402,7 @@ where
webcapture_auto_batch,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn create_work(
@@ -426,7 +418,7 @@ where
work_entity,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn create_work_auto_batch(
@@ -440,7 +432,7 @@ where
work_auto_batch,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn delete_container(
@@ -456,7 +448,7 @@ where
ident,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn delete_container_edit(
@@ -472,7 +464,7 @@ where
edit_id,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn delete_creator(
@@ -488,7 +480,7 @@ where
ident,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn delete_creator_edit(
@@ -504,7 +496,7 @@ where
edit_id,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn delete_file(
@@ -520,7 +512,7 @@ where
ident,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn delete_file_edit(
@@ -536,7 +528,7 @@ where
edit_id,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn delete_fileset(
@@ -552,7 +544,7 @@ where
ident,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn delete_fileset_edit(
@@ -568,7 +560,7 @@ where
edit_id,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn delete_release(
@@ -584,7 +576,7 @@ where
ident,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn delete_release_edit(
@@ -600,7 +592,7 @@ where
edit_id,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn delete_webcapture(
@@ -616,7 +608,7 @@ where
ident,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn delete_webcapture_edit(
@@ -632,7 +624,7 @@ where
edit_id,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn delete_work(
@@ -648,7 +640,7 @@ where
ident,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn delete_work_edit(
@@ -664,7 +656,7 @@ where
edit_id,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn get_changelog(
@@ -678,7 +670,7 @@ where
limit,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn get_changelog_entry(
@@ -692,7 +684,7 @@ where
index,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn get_container(
@@ -710,7 +702,7 @@ where
hide,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn get_container_edit(
@@ -724,7 +716,7 @@ where
edit_id,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn get_container_history(
@@ -740,7 +732,7 @@ where
limit,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn get_container_redirects(
@@ -754,7 +746,7 @@ where
ident,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn get_container_revision(
@@ -772,7 +764,7 @@ where
hide,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn get_creator(
@@ -790,7 +782,7 @@ where
hide,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn get_creator_edit(
@@ -804,7 +796,7 @@ where
edit_id,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn get_creator_history(
@@ -820,7 +812,7 @@ where
limit,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn get_creator_redirects(
@@ -834,7 +826,7 @@ where
ident,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn get_creator_releases(
@@ -850,7 +842,7 @@ where
hide,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn get_creator_revision(
@@ -868,7 +860,7 @@ where
hide,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn get_editgroup(
@@ -882,7 +874,7 @@ where
editgroup_id,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn get_editgroup_annotations(
@@ -898,7 +890,7 @@ where
expand,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn get_editgroups_reviewable(
@@ -918,7 +910,7 @@ where
since,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn get_editor(
@@ -932,7 +924,7 @@ where
editor_id,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn get_editor_annotations(
@@ -952,7 +944,7 @@ where
since,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn get_editor_editgroups(
@@ -972,7 +964,7 @@ where
since,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn get_file(
@@ -990,7 +982,7 @@ where
hide,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn get_file_edit(
@@ -1004,7 +996,7 @@ where
edit_id,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn get_file_history(
@@ -1020,7 +1012,7 @@ where
limit,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn get_file_redirects(
@@ -1034,7 +1026,7 @@ where
ident,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn get_file_revision(
@@ -1052,7 +1044,7 @@ where
hide,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn get_fileset(
@@ -1070,7 +1062,7 @@ where
hide,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn get_fileset_edit(
@@ -1084,7 +1076,7 @@ where
edit_id,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn get_fileset_history(
@@ -1100,7 +1092,7 @@ where
limit,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn get_fileset_redirects(
@@ -1114,7 +1106,7 @@ where
ident,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn get_fileset_revision(
@@ -1132,7 +1124,7 @@ where
hide,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn get_release(
@@ -1150,7 +1142,7 @@ where
hide,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn get_release_edit(
@@ -1164,7 +1156,7 @@ where
edit_id,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn get_release_files(
@@ -1180,7 +1172,7 @@ where
hide,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn get_release_filesets(
@@ -1196,7 +1188,7 @@ where
hide,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn get_release_history(
@@ -1212,7 +1204,7 @@ where
limit,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn get_release_redirects(
@@ -1226,7 +1218,7 @@ where
ident,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn get_release_revision(
@@ -1244,7 +1236,7 @@ where
hide,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn get_release_webcaptures(
@@ -1260,7 +1252,7 @@ where
hide,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn get_webcapture(
@@ -1278,7 +1270,7 @@ where
hide,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn get_webcapture_edit(
@@ -1292,7 +1284,7 @@ where
edit_id,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn get_webcapture_history(
@@ -1308,7 +1300,7 @@ where
limit,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn get_webcapture_redirects(
@@ -1322,7 +1314,7 @@ where
ident,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn get_webcapture_revision(
@@ -1340,7 +1332,7 @@ where
hide,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn get_work(
@@ -1358,7 +1350,7 @@ where
hide,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn get_work_edit(
@@ -1372,7 +1364,7 @@ where
edit_id,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn get_work_history(
@@ -1388,7 +1380,7 @@ where
limit,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn get_work_redirects(
@@ -1402,7 +1394,7 @@ where
ident,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn get_work_releases(
@@ -1418,7 +1410,7 @@ where
hide,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn get_work_revision(
@@ -1436,7 +1428,7 @@ where
hide,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn lookup_container(
@@ -1462,7 +1454,7 @@ where
hide,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn lookup_creator(
@@ -1482,7 +1474,7 @@ where
hide,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn lookup_editor(
@@ -1496,7 +1488,7 @@ where
username,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn lookup_file(
@@ -1518,7 +1510,7 @@ where
hide,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn lookup_release(
@@ -1543,7 +1535,7 @@ where
) -> Result<LookupReleaseResponse, ApiError> {
let context = context.clone();
info!("lookup_release({:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}", doi, wikidata_qid, isbn13, pmid, pmcid, core, arxiv, jstor, ark, mag, doaj, dblp, oai, hdl, expand, hide, context.get().0.clone());
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn update_container(
@@ -1561,7 +1553,7 @@ where
container_entity,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn update_creator(
@@ -1579,7 +1571,7 @@ where
creator_entity,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn update_editgroup(
@@ -1597,7 +1589,7 @@ where
submit,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn update_editor(
@@ -1613,7 +1605,7 @@ where
editor,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn update_file(
@@ -1631,7 +1623,7 @@ where
file_entity,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn update_fileset(
@@ -1649,7 +1641,7 @@ where
fileset_entity,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn update_release(
@@ -1667,7 +1659,7 @@ where
release_entity,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn update_webcapture(
@@ -1685,7 +1677,7 @@ where
webcapture_entity,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
async fn update_work(
@@ -1703,6 +1695,6 @@ where
work_entity,
context.get().0.clone()
);
- Err("Generic failuare".into())
+ Err(ApiError("Generic failure".into()))
}
}