RESTful API relevant

RESTful API

RESTful APIs explicitly take advantage of HTTP methodologies defined by the RFC 2616 protocol. They simply use "PUT" to change the state of or update a resource, which can be an object, file or block; "GET" to retrieve a resource; POST" to create that resource; and "DELETE" to remove it.

https://github.com/RestCheatSheet/api-cheat-sheet


RAML

An RAML example that demonstrate how to think about RESTful API

http://raml.org/developers/raml-200-tutorial

  • USE CASE
    Build a music Jukebox. While the physical device will be responsible for displaying the information and capturing the user input, it will be relying on your API to retrieve the information requested. The Jukebox needs to be able to:

    • Show the full list of artists.
    • Show the full list of albums.
    • Show the list of artists by nationality.
    • Show the list of albums by genre.
    • Search for a song by title.
    • Show a particular artist's albums collection.
    • Show a particular album's songs list.
    • Play a song (by specifying the song id).
    • Enter new Artists, Albums and Songs (only authenticated users).
  • Basic structure

/songs
  get
  post
  /{songId}
    get
    /file-content
      get
      post
/artists
  get
  post
    /{artistId}
      get
      /albums
        get
/albums
  get
  post
    /{albumId}
      get
      /songs
        get
  • Specify HTTP body parameter
    • form parameter
    • schema

RESTful API design and tools

http://blog.luisrei.com/articles/rest.html

Resources are mapped to URLs, actions are mapped to verbs and the rest goes in the headers.


API Design and Implementation Consideration

** For each of the following item, consider how to implement:**

For Flask

  • Request processing

    • url (@route)

    • http method

    • header (how to parse header)

    • body parameter (how to parse these parameter)

      • regular dictionary style parameter
      • file object ...
    • query parameter

  • Generate response

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 2017.08.31 充实的身份证生日!不得不记个流水账。 由于Alice的提醒,我发现原来生日时可以搜索关键词“...
    胡八道阅读 280评论 0 2
  • 春,檐下一颗种子悄悄冒尖 青是积累,春是成长 阳光雨露 是我成长的摇篮 烈日骄阳 是我生存的经历 凄风冷雨 是我成...
    只如初見無關風月阅读 242评论 1 2
  • 七个习惯签到20170411 【一、上周行动】 1.七个习惯 1.1 以终为始:定期整理细化个人目标,每天早上起来...
    白洲笔记阅读 200评论 0 2