Skip to content

Instantly share code, notes, and snippets.

@tarunama
Last active August 7, 2016 11:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tarunama/df99bd8bfeda6eab0f042275bf137f4a to your computer and use it in GitHub Desktop.
Save tarunama/df99bd8bfeda6eab0f042275bf137f4a to your computer and use it in GitHub Desktop.
HTTPメソッドの使い分け

HTTPメソッドの使い分け

  • GET
  • データリソースからデータを取得したい時
  • POST
  • データリソースに対して、データを新たに追加したい時
  • 例 ユーザーリスト(データソース)にデータ(ユーザー)を追加
POST /user/create/ HTTP/1.1
HOST: 127.0.0.1:8000
content-type: application/x-www-form-urlencoded

user_name=tarunama&user_country=JAPAN
  • PUT
  • データリソースに対して、変更を行う時。
  • 変更対象が存在しない時は、そのURLで新たにデータを作成しても良い。
PUT /v1/sample?id=123 HTTP/1.1
Host: example.com
Content-Type: application/json
Content-Length: 21

{"name":"yahoo taro"}

参考

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment