Link headers vs link elements for RESTful JSON

后端 未结 5 1604
余生分开走
余生分开走 2021-02-01 04:09

When building a RESTful / hypermedia API with JSON resources, it seems I have two options for specifying the hypermedia relationships between resources.

  1. Embed t

5条回答
  •  攒了一身酷
    2021-02-01 04:32

    • Link headers can be considered by intermediaries
    • Link headers are compressed by SPDY
    • Link headers are standard

    They can even contain some JSON if needed! http://tools.ietf.org/html/draft-nottingham-link-hint-00

    This approach allows delivery at the same time in all responses:

    • Link Headers containing hypermedia information
    • a payload devoted to resource representation

    Of course the resource representation may contain links encoded in various forms, but the use of Link headers can provide the most important part of the dynamic structure of your site.

    What makes this solution definitively appealing is IMHO the "accept-post" hint.

提交回复
热议问题