aboutsummaryrefslogtreecommitdiffstats
path: root/rust/src/endpoint_handlers.rs
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2019-05-09 00:05:49 -0700
committerBryan Newbold <bnewbold@robocracy.org>2019-05-09 00:05:49 -0700
commit4bb302f16ed01643864a14a183c663a201943ff3 (patch)
treeaa7563579e62f87bb9fa6b35717bbe88d945ff90 /rust/src/endpoint_handlers.rs
parentbf63870c88b5a62a2aad08929465b37d8be474dc (diff)
downloadfatcat-4bb302f16ed01643864a14a183c663a201943ff3.tar.gz
fatcat-4bb302f16ed01643864a14a183c663a201943ff3.zip
initial API schema rust impl
Diffstat (limited to 'rust/src/endpoint_handlers.rs')
-rw-r--r--rust/src/endpoint_handlers.rs38
1 files changed, 30 insertions, 8 deletions
diff --git a/rust/src/endpoint_handlers.rs b/rust/src/endpoint_handlers.rs
index f43b3559..cd2f1afa 100644
--- a/rust/src/endpoint_handlers.rs
+++ b/rust/src/endpoint_handlers.rs
@@ -263,6 +263,8 @@ impl Server {
core_id: &Option<String>,
arxiv_id: &Option<String>,
jstor_id: &Option<String>,
+ ark_id: &Option<String>,
+ mag_id: &Option<String>,
expand_flags: ExpandFlags,
hide_flags: HideFlags,
) -> Result<ReleaseEntity> {
@@ -275,8 +277,10 @@ impl Server {
core_id,
arxiv_id,
jstor_id,
+ ark_id,
+ mag_id,
) {
- (Some(doi), None, None, None, None, None, None, None) => {
+ (Some(doi), None, None, None, None, None, None, None, None, None) => {
// DOIs always stored lower-case; lookups are case-insensitive
let doi = doi.to_lowercase();
check_doi(&doi)?;
@@ -287,7 +291,7 @@ impl Server {
.filter(release_ident::redirect_id.is_null())
.first(conn)?
}
- (None, Some(wikidata_qid), None, None, None, None, None, None) => {
+ (None, Some(wikidata_qid), None, None, None, None, None, None, None, None) => {
check_wikidata_qid(wikidata_qid)?;
release_ident::table
.inner_join(release_rev::table)
@@ -296,7 +300,7 @@ impl Server {
.filter(release_ident::redirect_id.is_null())
.first(conn)?
}
- (None, None, Some(isbn13), None, None, None, None, None) => {
+ (None, None, Some(isbn13), None, None, None, None, None, None, None) => {
// TODO: check_isbn13(isbn13)?;
release_ident::table
.inner_join(release_rev::table)
@@ -305,7 +309,7 @@ impl Server {
.filter(release_ident::redirect_id.is_null())
.first(conn)?
}
- (None, None, None, Some(pmid), None, None, None, None) => {
+ (None, None, None, Some(pmid), None, None, None, None, None, None) => {
check_pmid(pmid)?;
release_ident::table
.inner_join(release_rev::table)
@@ -314,7 +318,7 @@ impl Server {
.filter(release_ident::redirect_id.is_null())
.first(conn)?
}
- (None, None, None, None, Some(pmcid), None, None, None) => {
+ (None, None, None, None, Some(pmcid), None, None, None, None, None) => {
check_pmcid(pmcid)?;
release_ident::table
.inner_join(release_rev::table)
@@ -323,7 +327,7 @@ impl Server {
.filter(release_ident::redirect_id.is_null())
.first(conn)?
}
- (None, None, None, None, None, Some(core_id), None, None) => {
+ (None, None, None, None, None, Some(core_id), None, None, None, None) => {
// TODO: check_core_id(core_id)?;
release_ident::table
.inner_join(release_rev::table)
@@ -332,7 +336,7 @@ impl Server {
.filter(release_ident::redirect_id.is_null())
.first(conn)?
}
- (None, None, None, None, None, None, Some(arxiv_id), None) => {
+ (None, None, None, None, None, None, Some(arxiv_id), None, None, None) => {
// TODO: check_arxiv_id(arxiv_id)?;
release_ident::table
.inner_join(release_rev::table)
@@ -341,7 +345,7 @@ impl Server {
.filter(release_ident::redirect_id.is_null())
.first(conn)?
}
- (None, None, None, None, None, None, None, Some(jstor_id)) => {
+ (None, None, None, None, None, None, None, Some(jstor_id), None, None) => {
// TODO: check_jstor_id(jstor_id)?;
release_ident::table
.inner_join(release_rev::table)
@@ -350,6 +354,24 @@ impl Server {
.filter(release_ident::redirect_id.is_null())
.first(conn)?
}
+ (None, None, None, None, None, None, None, None, Some(ark_id), None) => {
+ // TODO: check_ark_id(ark_id)?;
+ release_ident::table
+ .inner_join(release_rev::table)
+ .filter(release_rev::ark_id.eq(ark_id))
+ .filter(release_ident::is_live.eq(true))
+ .filter(release_ident::redirect_id.is_null())
+ .first(conn)?
+ }
+ (None, None, None, None, None, None, None, None, None, Some(mag_id)) => {
+ // TODO: check_ark_id(ark_id)?;
+ release_ident::table
+ .inner_join(release_rev::table)
+ .filter(release_rev::mag_id.eq(mag_id))
+ .filter(release_ident::is_live.eq(true))
+ .filter(release_ident::redirect_id.is_null())
+ .first(conn)?
+ }
_ => {
return Err(
FatcatError::MissingOrMultipleExternalId("in lookup".to_string()).into(),