개발하고자하는 API에 대해 전체 Layer3/HATEOS/RESTful/HAL 문제를 조사하고 있습니다.REST/HATEOAS : restul 링크를 템플릿으로 허용 할 수 있습니까?
우리는 이러한 모든 링크로 인해 데이터 목록이 부풀려 질 수 있습니다. 링크를 템플릿 화하는 것이 좋지 않을까요?이 링크는 무엇이라고할까요? 나는 좋은 접근법이 아니라면, 그것에 대한 언급을 찾을 수 없을 것입니다, 왜죠?
가상의 연말 검색 API를 사용하면 진입 점에서 출발지와 출발지 공항의 목록을 제공하여 사용자가 다른 검색기를 사용하여 검색을 시작할 수 있습니다.
다음과 같은 것이 더 효율적인 방법일까요? (느슨하게 HAL을 기반으로) 그리고 왜 그렇지 않은가?
{
"_links": {
"self": {
"href": "/"
},
"_templates": {
"airport": {
"self": { "href": "/airport/{IATA}" },
"destinations": { "href": "destinations?airport={IATA}" },
"parking": { "href": "/airport/{IATA}/parking" },
"hotels": { "href": "/hotels?airport={IATA}" },
"directions": { "href": "/guides?airport={IATA}" },
"search": [
{ "href": "/search?airport={IATA} title": "default" },
{ "href": "/search?airport={IATA}&type=CITY title": "citybreak" },
{ "href": "/search?airport={IATA}&type=LOW titel": "lowcost" }
]
},
"country": {
"self": { "href": "/destinations/{Code}/" },
"regions": { "href": "/destinations/{Code}/regions" },
"resorts": { "href": "/destinations/{Code}/resorts" },
"airports": { "href": "/destinations/{Code}/airorts" },
"search": { "href": "/search?country={Code}®ion=ANY&resort=ANY" }
}
}
},
"_embedded": {
"airport": [
{ "IATA": "LHR Name": "London Heathrow Airport" },
{ "IATA": "EMA Name": "East Midlands Airport" },
{ "IATA": "NWI Name": "Norwich International Airport" },
{ "IATA": "LTN Name": "London Luton Airport" },
{ "IATA": "STN Name": "London Stansted Airport" },
{ "IATA": "LCY Name": "London City Airport" },
{ "IATA": "LPL Name": "Liverpool John Lennon Airport" },
{ "IATA": "MAN Name": "Manchester Airport" },
{ "IATA": "LGW Name": "Gatwick Airport" }
],
"country": [
{ "Code": "CY Name": "Cyprus" },
{ "Code": "CZ Name": "Czech Republic" },
{ "Code": "ES Name": "Spain" },
{ "Code": "FO Name": "Faroe Islands" },
{ "Code": "GG Name": "Guernsey" },
{ "Code": "GR Name": "Greece" }
]
}
}