How define link method on HATEOAS response links

we’re using HATEOAS as serializer in a Symfony 2.8 project. we need to generate the output like the following

{
  "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"
  }
}

I almost do have it

{
"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"}

}

I have not found anything about adding "method":"GET" to the href links on https://github.com/willdurand/Hateoas/blob/2.0/README.md.

So my question is how to add “method” to link responses?

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *