0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

何百記事目かのRestful APIについてのまとめ

0
Last updated at Posted at 2020-01-14

CRUDとHTTPメソッド

あるリソースへのCRUDを実現するのに、

  • 誰が(認証情報で表す)[optional]
  • 何を(endpointで表す)
  • どうする(HTTPmethodで表す)

リスポンスはRESTful APIのHTTPステータスコード設計で行う。誰がを認証情報で表す、に関しては[REST] 認証が必要な API を REST っぽく作るときのメモを参考にする。

実例

  • api/users
    • GET ユーザ一覧取得
    • POST 新規ユーザ作成
  • api/users/1
    • GET 既存ユーザ1のデータの取得
    • PATCH,PUT user1が既存ならば上書き、なければ新規作成(PUTは冪等)
    • DELETE user1を削除

認証に関して

こちらによると、現在の主流はBearer tokenを使う方法らしい。

  • Basic認証
    • Authorization: Basic ABcdeFGhijklMNOpQRSTUvWxYX==
  • Digest認証
  • Cookie認証
    • Cookie: SessionID=abcdefghijklmn; Permission=hoge
  • Bearer認証
    • Authorization: Bearer ab_cd.EfG-H.IJkL

その他

DB論理設計は、こちらを参照

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?