Closed rizen closed 5 months ago
variants we considered
"links" : {
"GET" : {
"base" : "http://localhost:3000/api/user",
"self" : "http://localhost:3000/api/user/xxx",
"apikeys" : "http://localhost:3000/api/user/xxx/apikeys",
"avatar" : "http://someavatarsite.org/user/xxx.svg",
},
"POST" : {
"base" : "http://localhost:3000/api/user",
},
"PUT" : {
"self" : "http://localhost:3000/api/user/xxx",
},
"DELETE" : {
"self" : "http://localhost:3000/api/user/xxx",
}
...
}
"links" : {
"http://localhost:3000/api/user" : ['GET','POST','PUT','DELETE'],
"http://localhost:3000/api/user/xxx" : ['GET','PUT','DELETE'],
"http://localhost:3000/api/user/xxx/apikeys" : ['GET'],
"http://someavatarsite.org/user/xxx.svg" : ['GET'],
...
}
"links" : {
"base" : {
"href" : "http://localhost:3000/api/user",
"methods" : ['GET','POST']
},
"self" : {
"href" : "http://localhost:3000/api/user/xxx",
"methods" : ['GET','POST']
},
"avatar" : {
"href" : "http://someavatarsite.org/user/xxx.svg",
"methods" : ['GET']
},
"apikeys" : {
"href" : "http://localhost:3000/api/user/xxx/apikeys",
"methods" : ['GET']
},
}
Current version is so light weight though:
"links" : {
"base" : "/api/user",
"self" : "/api/user/xxx",
"apikeys" : "/api/user/xxx/apikeys",
...
}
switch to using links like this in the response as it would work for object relationships and human links alike
'links' => [ { 'method' => 'GET', 'rel' => 'self', 'href' => 'https://api.sandbox.paypal.com/v2/checkout/orders/3L991810LA4523710' }, { 'href' => 'https://www.sandbox.paypal.com/checkoutnow?token=3L991810LA4523710', 'rel' => 'approve', 'method' => 'GET' }, { 'method' => 'PATCH', 'rel' => 'update', 'href' => 'https://api.sandbox.paypal.com/v2/checkout/orders/3L991810LA4523710' }, { 'method' => 'POST', 'rel' => 'capture', 'href' => 'https://api.sandbox.paypal.com/v2/checkout/orders/3L991810LA4523710/capture' } ]