Skip to content

Commit

Permalink
urn:nato
Browse files Browse the repository at this point in the history
  • Loading branch information
fititnt committed Sep 29, 2022
1 parent 2ee0698 commit b49c884
Show file tree
Hide file tree
Showing 28 changed files with 147 additions and 46 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -300,4 +300,4 @@ has waived all copyright and related or neighboring rights to this work to
[Public Domain](UNLICENSE).

Optionally, you can choose to use the [MIT License](https://opensource.org/licenses/MIT)
instead of Public Domain unlicense.
instead of Public Domain unlicense.
23 changes: 6 additions & 17 deletions app/lib/urnresolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ public function execute()
{
// echo strpos($this->active_urn, 'urn:resolver:') ;
// die($this->active_urn);
// $mode = 'default';
$mode = 'default';
if (strpos($this->active_urn, 'urn:resolver:') === 0) {
$urnr = new ResponseURNResolver($this, $this->active_urn);
if ($urnr->execute()) {
Expand All @@ -531,23 +531,12 @@ public function execute()
$resp = new Response($this->config);
$resp->execute_output_5xx($this->active_uri);
}
die;
} else {
// die($mode);
$resp = new Response($this->config, $mode);
$target = $this->config->transform_if_necessary($this->active_urn_to_uri);
$resp->execute_redirect($target, $this->active_urn_to_httpstatus);
}
// die($mode);
$resp = new Response($this->config, $mode);
$target = $this->config->transform_if_necessary($this->active_urn_to_uri);
$resp->execute_redirect($target, $this->active_urn_to_httpstatus);
die();

http_response_code($this->active_urn_to_httpstatus);
// @see https://developers.cloudflare.com/cache/about/cache-control/
// This log really needs be reviewned later
header('Cache-Control: public, max-age=3600, s-maxage=600, stale-while-revalidate=600, stale-if-error=600');
// header('Vary: Accept-Encoding');
// header("Access-Control-Allow-Origin: *");
header('Location: ' . $this->active_urn_to_uri);
die();
// header("HTTP/1.1 301 Moved Permanently");
}

public function execute_welcome()
Expand Down
1 change: 1 addition & 0 deletions app/public/.well-known/urn/urn.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ urn:git:github:(.*).urnr.json
urn:ietf:(.*).urnr.json
urn:issn:(.*).urnr.json
urn:lex:br:(.*).urnr.json
urn:nato:(.*).urnr.json
urn:purl:(.*).urnr.json
urn:resolver:(.*).urnr.json
urn:w3id:(.*).urnr.json
3 changes: 2 additions & 1 deletion app/public/.well-known/urn/urn:doi:(.*).urnr.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"_meta": {
"$schema": "urn:resolver:schema:urnr",
"meta": {
"spec": "https://www.doi.org/doi_handbook/2_Numbering.html#2.6.3",
"examples": [
{
Expand Down
3 changes: 2 additions & 1 deletion app/public/.well-known/urn/urn:geo:(.*).urnr.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"_meta": {
"$schema": "urn:resolver:schema:urnr",
"meta": {
"spec": [
"https://www.rfc-editor.org/rfc/rfc5870",
"https://en.wikipedia.org/wiki/Geo_URI_scheme",
Expand Down
3 changes: 2 additions & 1 deletion app/public/.well-known/urn/urn:git:gitee:(.*).urnr.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"_meta": {
"$schema": "urn:resolver:schema:urnr",
"meta": {
"spec": [
"https://gitee.com/api/v5/swagger"
],
Expand Down
3 changes: 2 additions & 1 deletion app/public/.well-known/urn/urn:git:github:(.*).urnr.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"_meta": {
"$schema": "urn:resolver:schema:urnr",
"meta": {
"spec": [
"https://docs.github.com/rest"
],
Expand Down
3 changes: 2 additions & 1 deletion app/public/.well-known/urn/urn:ietf:(.*).urnr.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"_meta": {
"$schema": "urn:resolver:schema:urnr",
"meta": {
"_note": "this resolver rule is an early working draft",
"spec": "https://datatracker.ietf.org/doc/html/rfc2648",
"examples": [
Expand Down
3 changes: 2 additions & 1 deletion app/public/.well-known/urn/urn:issn:(.*).urnr.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"_meta": {
"$schema": "urn:resolver:schema:urnr",
"meta": {
"spec": "https://en.wikipedia.org/wiki/International_Standard_Serial_Number#Use_in_URNs",
"examples": [
{
Expand Down
3 changes: 2 additions & 1 deletion app/public/.well-known/urn/urn:lex:br:(.*).urnr.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"_meta": {
"$schema": "urn:resolver:schema:urnr",
"meta": {
"spec": [
"https://en.wikipedia.org/wiki/LexML"
],
Expand Down
27 changes: 27 additions & 0 deletions app/public/.well-known/urn/urn:nato:(.*).urnr.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"$schema": "urn:resolver:schema:urnr",
"meta": {
"_comment": "See RFC 7467. Both <http://nso.nato.int/nso/nsdd/listpromulg.html> and <https://nhqc3s.hq.nato.int/Default.aspx> are public, so at least some sort of which standards exist (but contents are not public).\n",
"spec": [
"https://www.rfc-editor.org/rfc/rfc7467"
],
"examples": [
{
"in.urn": "urn:nato:",
"out.[0].iri": "https://www.nato.int/"
}
]
},
"rules": [
{
"in": {
"urn": "urn:nato:(.*)"
},
"out": [
{
"iri": "https://nato.int/{{ in[1] }}"
}
]
}
]
}
3 changes: 2 additions & 1 deletion app/public/.well-known/urn/urn:purl:(.*).urnr.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"_meta": {
"$schema": "urn:resolver:schema:urnr",
"meta": {
"spec": [
"https://en.wikipedia.org/wiki/Persistent_uniform_resource_locator"
],
Expand Down
3 changes: 2 additions & 1 deletion app/public/.well-known/urn/urn:resolver:(.*).urnr.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"_meta": {
"$schema": "urn:resolver:schema:urnr",
"meta": {
"_internal": true,
"Cache-Control": {
"_cc_mode": "internal"
Expand Down
3 changes: 2 additions & 1 deletion app/public/.well-known/urn/urn:w3id:(.*).urnr.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"_meta": {
"$schema": "urn:resolver:schema:urnr",
"meta": {
"spec": [
"https://en.wikipedia.org/wiki/Persistent_uniform_resource_locator"
],
Expand Down
24 changes: 21 additions & 3 deletions app/public/meta/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,32 @@
# URN Resolver / Meta

## urnresolver.context.jsonld
## Files
### urnresolver.context.jsonld
> - [urnresolver.context.jsonld](urnresolver.context.jsonld)
Prefixes uses https://github.com/w3c/json-ld-rc/ (https://w3c.github.io/json-ld-rc/context.jsonld) as reference

## urnresolver.schema.json
### urnresolver.schema.json
> - [urnresolver.schema.json](urnresolver.schema.json)
## Relation to other APIs

### OpenAPI
> - https://www.openapis.org/
While this varies by individual URN Resolver deployment, we do have a handcrafted OpenAPI.

### JSON-API
> - https://jsonapi.org/
At least the top level of the API response is fully compatible with JSON API 1.0 & JSON API 1.1.

<!--
https://urn.etica.ai/meta/test-api-online.json
- https://jschon.dev/
- https://json-schema.hyperjump.io/ (accepts YAML)
- https://onlineyamltools.com/convert-yaml-to-json
- https://urn.etica.ai/meta/test-api-online.json
- https://json-everything.net/json-schema/
-->


25 changes: 25 additions & 0 deletions app/public/meta/urnresolver-urnr.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "urn:resolver:schema:urnr",
"title": "URN Resolver JSON Schema",
"description": "Early draft. See https://github.com/EticaAI/urn-resolver/issues/2",
"type": "object",
"additionalProperties": false,
"properties": {
"$id": {
"type": "string"
},
"$schema": {
"type": "string"
},
"rules": {
"type": "array"
},
"meta": {
"type": "object"
}
},
"required": [
"rules"
]
}
9 changes: 8 additions & 1 deletion app/urnresolver.dist.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
"//comment": "Rename urnresolver.dist.conf.json to urnresolver.conf.json",
"base_iri": "http://localhost:8000",
"resolver_status_pages": ["https://stats.uptimerobot.com/z6Y43IGQkL"],
"caching-groups": {
"//@TODO": "implement groups like this mode",
"default": {
"Cache-Control": {},
"Surrogate-Control": {}
}
},
"Cache-Control": {
"default": {
"_cc_prefix": "public",
Expand Down Expand Up @@ -46,4 +53,4 @@
"stale-if-error": 10
}
}
}
}
5 changes: 3 additions & 2 deletions resolvers/urn:doi:(.*).urnr.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
_meta:
$schema: urn:resolver:schema:urnr
meta:
spec: https://www.doi.org/doi_handbook/2_Numbering.html#2.6.3
examples:
- in.urn: urn:doi:10.1000/182
Expand All @@ -13,4 +14,4 @@ rules:
out:
- iri: "https://doi.org/{{ in[0] }}"
lb_w: 100
http_status: 302
http_status: 302
3 changes: 2 additions & 1 deletion resolvers/urn:geo:(.*).urnr.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
_meta:
$schema: urn:resolver:schema:urnr
meta:
spec:
- https://www.rfc-editor.org/rfc/rfc5870
- https://en.wikipedia.org/wiki/Geo_URI_scheme
Expand Down
3 changes: 2 additions & 1 deletion resolvers/urn:git:gitee:(.*).urnr.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
_meta:
$schema: urn:resolver:schema:urnr
meta:
spec:
- https://gitee.com/api/v5/swagger
examples:
Expand Down
3 changes: 2 additions & 1 deletion resolvers/urn:git:github:(.*).urnr.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
_meta:
$schema: urn:resolver:schema:urnr
meta:
spec:
- https://docs.github.com/rest
examples:
Expand Down
6 changes: 3 additions & 3 deletions resolvers/urn:ietf:(.*).urnr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
# urn:ietf:id:ietf-urn-ietf-06
# urn:ietf:mtg:41-urn
# urn:ietf:bcp:47

_meta:
$schema: urn:resolver:schema:urnr
meta:
_note: this resolver rule is an early working draft
spec: https://datatracker.ietf.org/doc/html/rfc2648
examples:
Expand All @@ -31,4 +31,4 @@ rules:
urn: "urn:ietf:(.*)"
out:
- iri: "https://www.rfc-editor.org/info/{{ in[1] }}"
http_status: 302
http_status: 302
3 changes: 2 additions & 1 deletion resolvers/urn:issn:(.*).urnr.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
_meta:
$schema: urn:resolver:schema:urnr
meta:
spec: https://en.wikipedia.org/wiki/International_Standard_Serial_Number#Use_in_URNs
examples:
- in.urn: urn:issn:1476-4687
Expand Down
3 changes: 2 additions & 1 deletion resolvers/urn:lex:br:(.*).urnr.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# @see https://pt.wikipedia.org/wiki/Lex_(URN)
# @see https://projeto.lexml.gov.br/documentacao/destaques-lexml#nomes-persistentes
# full example: https://www.lexml.gov.br/urn/urn:lex:br:federal:lei:2008-06-19;11705
_meta:
$schema: urn:resolver:schema:urnr
meta:
spec:
- https://en.wikipedia.org/wiki/LexML
# - https://en.wikipedia.org/wiki/EUR-Lex
Expand Down
16 changes: 16 additions & 0 deletions resolvers/urn:nato:(.*).urnr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
$schema: urn:resolver:schema:urnr
meta:
_comment: >
See RFC 7467. Both <http://nso.nato.int/nso/nsdd/listpromulg.html> and
<https://nhqc3s.hq.nato.int/Default.aspx> are public, so at least some
sort of which standards exist (but contents are not public).
spec:
- https://www.rfc-editor.org/rfc/rfc7467
examples:
- in.urn: 'urn:nato:'
out.[0].iri: https://www.nato.int/
rules:
- in:
urn: "urn:nato:(.*)"
out:
- iri: "https://nato.int/{{ in[1] }}"
3 changes: 2 additions & 1 deletion resolvers/urn:purl:(.*).urnr.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
_meta:
$schema: urn:resolver:schema:urnr
meta:
spec:
- https://en.wikipedia.org/wiki/Persistent_uniform_resource_locator
examples:
Expand Down
4 changes: 2 additions & 2 deletions resolvers/urn:resolver:(.*).urnr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
# urn_resolver_internal: true

# https://stats.uptimerobot.com/jYDZlFY8jq

_meta:
$schema: urn:resolver:schema:urnr
meta:
_internal: true
Cache-Control:
_cc_mode: internal
Expand Down
3 changes: 2 additions & 1 deletion resolvers/urn:w3id:(.*).urnr.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
_meta:
$schema: urn:resolver:schema:urnr
meta:
spec:
- https://en.wikipedia.org/wiki/Persistent_uniform_resource_locator
examples:
Expand Down

0 comments on commit b49c884

Please sign in to comment.