- RESTful Web API Design with Node.js 10
- Valentin Bojinov
- 118字
- 2021-08-27 18:37:24
Principle 4 – Resources can have multiple representations
A key feature of a resource is that it may be represented in a different format from the one in which it is stored. Thus, it can be requested or created in different representations. As long as the specified format is supported, the REST-enabled endpoint should use it. In the preceding example, we posted an XML representation of a watch item, but if the server had supported the JSON format, the following request would have been valid as well:
POST /categories/watches HTTP/1.1 Content-Type: application/json Host: www.mycatalog.com { "watch": { "id": ""watch-abc"", "brand": "...", "price": { "-currency": "EUR", "#text": "100" } } } HTTP/1.1 201 Created Content-Type: application/json Location: http://mycatalog.com/categories/watches/watch-abc
推薦閱讀
- Three.js開發指南:基于WebGL和HTML5在網頁上渲染3D圖形和動畫(原書第3版)
- Servlet/JSP深入詳解
- Python數據分析從0到1
- Getting Started with Hazelcast(Second Edition)
- Learning Material Design
- 鴻蒙OS應用編程實戰
- Mastering Concurrency Programming with Java 9(Second Edition)
- Visual Basic語言程序設計基礎(第3版)
- Java 9 with JShell
- Blender 3D Cookbook
- JavaScript設計模式與開發實踐
- Instant AppFog
- Mastering Unity 2017 Game Development with C#(Second Edition)
- jQuery EasyUI從零開始學
- Sony Vegas Pro 11 Beginner’s Guide