API の設計を開始し、REST/HATEOAS に準拠させることにしました。API のエントリ ポイントは何にする必要がありますか?
一般的なもののように思えますが、実際には取得するためのリソースがないため、GET /
を使用する方が論理的に理にかなっている可能性があります。OPTIONS /
/
ここでは、JSON のHAL構文をハイパーメディア形式として使用して、両方の例を示しました。
得る /
リクエスト:
GET / HTTP/1.1
Host: example.com
応答:
HTTP/1.1 200 OK
Date: …
Content-Type: application/json;charset=utf-8
Content-Length: 143
{
"_links": {
"self": {
"href": "/"
},
"penguins": {
"href": "/penguins"
}
}
}
オプション /
リクエスト:
OPTIONS / HTTP/1.1
Host: example.com
応答:
HTTP/1.1 200 OK
Date: …
Allow: OPTIONS
Content-Type: application/json;charset=utf-8
Content-Length: 143
{
"_links": {
"self": {
"href": "/"
},
"penguins": {
"href": "/penguins"
}
}
}