我们在Symfony 2.8项目中将HATEOAS用作序列化程序。我们需要生成如下所示的输出
{
"user": {
"id": 1,
"name": "string",
"_links": {
"self": {
"href": "/merchant/view/123",
"method": "GET"
}
}
},
"merchant": {
"id": 123,
"name": "string",
"_links": {
"self": {
"href": "/merchant/view/123",
"method": "GET"
}
}
},
"transportOrder": {
"createdOn": "2019-12-11T14:12:58"
}
}
我几乎有它
{
"user":{"id":1707057,"name":"FirstName lastName","_links":{"self":{"href":"\/merchant\/view\/1707057"}}},
"merchant":{"id":1707057,"name":"Company","_links":{"self":{"href":"\/merchant\/view\/1707057"}}},
"transportOrder":{"createdOn":"2020-01-01T00:00:00+0000"}
}
对于在https://github.com/willdurand/Hateoas/blob/2.0/README.md上的"method":"GET"
链接中添加href
并没有任何发现。
所以我的问题是如何添加“方法”以链接响应?