cthoyt / cthoyt.github.io

My personal website, served at https://cthoyt.com
https://cthoyt.com/
Creative Commons Attribution 4.0 International
3 stars 4 forks source link

Re-implementing the N2T ARK Resolver | Biopragmatics #53

Open utterances-bot opened 1 year ago

utterances-bot commented 1 year ago

Re-implementing the N2T ARK Resolver | Biopragmatics

Archival Resource Keys (ARKs) are flavor of persistent identifiers like DOIs, URNs, and Handles that have the benefit of being free, flexible with what metadata gets attached, and natively able to resolve to web pages. Name-to-Thing (N2T) implements a resolver for a variety of ARKs, so this blog post is about how that resolver can be re-implemented with the curies Python package.

https://cthoyt.com/2023/04/11/n2t-ark-resolver.html

dwinston commented 1 year ago

Cool! Re: the ark:/ to ark: migration, it is intended that any resolver support both the old-style expression (with a / after ark:) and the new one. If you can update to support both, that would be excellent.

well done!

cthoyt commented 1 year ago

I think this is possible, but I can't imagine it being elegant. Some ideas:

  1. if I mount two different resolver apps on different url_prefix's.
  2. Maybe there are also some deep dark magics in URL routing I could use too, but it won'
dwinston commented 1 year ago

My strategy has been a blanket rewrite-and-redirect in a FastAPI app:

@app.get(
    "/ark:/{naan}/{rest_of_path:path}",
    response_class=RedirectResponse,
    tags=["util"],
    summary="Get ARK (Slash Before NAAN)",
)
async def _ark(naan: ArkNaan, request: Request):
    """normalize request to not have slash (/) preceding ark naan."""
    return RedirectResponse(
        url=str(request.url).replace("ark:/", "ark:"), status_code=301
    )

Source: https://github.com/polyneme/ns/blob/b7650f682421f639a09fb36491e8126eea08c668/xyz_polyneme_ns/main.py#L900

dwinston commented 1 year ago

I know this can be done at a higher level, e.g. at a reverse proxy level via e.g. an Apache RewriteRule, but it would be nice to work "out of the box" for n2t-ark-resolver.

juhahakala commented 1 year ago

The new URN syntax (RFC 8141) does allow the use of slash, so it is up to the ARK community to decide whether to keep it. So an ARK like ark:/53355/cl010277627 may be left unchanged or converted to URN urn:ark:53355/cl010277627. IMO the version without the slash looks better. I don't know if the ARK alliance is planning to register a URN namespace, but I would welcome such decision.