Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
PUTとPOSTどっち使う?
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Hank Ehly
June 23, 2022
Technology
1.2k
0
Share
PUTとPOSTどっち使う?
https://qiita.com/hankehly/items/ed7e699ebe89f14b2ff7
Hank Ehly
June 23, 2022
More Decks by Hank Ehly
See All by Hank Ehly
Fivetranでデータ移動を自動化する
hankehly
0
650
Celeryの紹介と本番運用のTips
hankehly
0
1.5k
ChatGPTを活用した 便利ツールの紹介
hankehly
1
1.4k
Efficient Energy Analytics with Airflow, Spark, and MLFlow
hankehly
0
390
Deferrable Operators入門
hankehly
0
740
【初心者/ハンズオン】Dockerコンテナの基礎知識
hankehly
0
590
Compositeパターン: オブジェクトの階層関係をエレガントに表現する方法
hankehly
0
350
10/29 Airflowの基礎を学ぶハンズオンワークショップ
hankehly
0
300
システム/データ品質保証のための Airflow 活用法
hankehly
0
670
Other Decks in Technology
See All in Technology
Oracle Cloud Infrastructure presents managed, serverless MCP Servers for Oracle AI Database
thatjeffsmith
0
240
フロントエンドの相手が変わった - AIが加わったWebの新しいインターフェース設計
azukiazusa1
33
11k
みんなの考えた最強のデータ基盤アーキテクチャ'26前期〜前夜祭〜ルーキーズ_資料_遠藤な
endonanana
0
310
エンタープライズの厳格な制約を開発者に意識させない:クラウドネイティブ開発基盤設計/cloudnative-kaigi-golden-path
mhrtech
0
400
可視化から活用へ — Mesh化・Segmentation・アライメントの研究動向
gpuunite_official
0
170
Oracle AI Database@Azure:サービス概要のご紹介
oracle4engineer
PRO
6
1.6k
古今東西SRE
okaru
2
180
Oracle AI Database@AWS:サービス概要のご紹介
oracle4engineer
PRO
4
2.5k
AIの揺らぎに“コシ”を与える階層化品質設計
ickx
0
270
試作とデモンストレーション / Prototyping and Demonstrations
ks91
PRO
0
200
10サービス以上のメール到達率改善を地道に継続的に進めている話 / Continue to improve email delivery rates across multiple services
yamaguchitk333
6
1.6k
SLI/SLO、「完全に理解した」から「チョットデキル」へ
maruloop
5
430
Featured
See All Featured
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
180
Leo the Paperboy
mayatellez
7
1.8k
A Modern Web Designer's Workflow
chriscoyier
698
190k
The SEO identity crisis: Don't let AI make you average
varn
0
460
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
320
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
190
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
Designing for humans not robots
tammielis
254
26k
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
420
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
210
Evolving SEO for Evolving Search Engines
ryanjones
0
190
Transcript
PUTとPOSTどっち使う? qiita.com/hankehly > PUTとPOSTどっち使う?
自己紹介 • Hank Ehly (ハンク イーリー) • ENECHANGE株式会社 • qiita.com/hankehly
• connpass.com/user/hankehly • github.com/hankehly • speakerdeck.com/hankehly qiita.com/hankehly > PUTとPOSTどっち使う?
アジェンダ 1. PUTとPOSTの違い 2. POST 3. PUT qiita.com/hankehly > PUTとPOSTどっち使う?
百億%忘れてい るぜ
1 0 意識している あまり意識しない チャットに投稿してください Web APIを開発する上で PUTとPOSTの違いを…
PUTとPOSTの違い qiita.com/hankehly > PUTとPOSTどっち使う?
• リクエストに同封されているデータの意図 The fundamental difference between the POST and PUT
methods is highlighted by the different intent for the enclosed representation (RFC7231) • 使い分けることで、表現力の高い、理解しやすい Web API が作れる PUTとPOSTの違い qiita.com/hankehly > PUTとPOSTどっち使う?
PUTとPOSTの違い リソース 新規作成 バッチ処理開始 データ削除 POST PUT リソース 置き換え ファイル
アップロード qiita.com/hankehly > PUTとPOSTどっち使う?
POST
POST • 受け取ったデータで何してもおかしくない • 汎用的 リクエスト レスポンス DBレコードを INSERT する
201 (Created) ファイルを削除する 204 (No Content) 非同期処理を開始する 202 (Accepted) キャッシュされたリソースにリダイレクトする 303 (See Other) qiita.com/hankehly > PUTとPOSTどっち使う? • 一般的に冪等性がないため、キャッシュの対象にならない
POST /articles HTTP/1.1 { "name": "foo", "author": "tanaka", "content": "hello
world" } HTTP/1.1 201 Created Location: http://example.com/articles/12 POST • リソースの新規作成に使うことが多い qiita.com/hankehly > PUTとPOSTどっち使う?
POST • リソースの新規作成に使うことが多い POST /articles HTTP/1.1 { "name": "foo", "author":
"tanaka", "content": "hello world" } HTTP/1.1 201 Created Location: http://example.com/articles/12 qiita.com/hankehly > PUTとPOSTどっち使う?
POST • リソースの新規作成に使うことが多い POST /articles HTTP/1.1 { "name": "foo", "author":
"tanaka", "content": "hello world" } HTTP/1.1 201 Created Location: http://example.com/articles/12 qiita.com/hankehly > PUTとPOSTどっち使う?
PUT
PUT • 対象リソースの置き換え(丸ごと) • どのリソースを置き換えるか知っている必要がある ◦ PUT /articles/12 • 冪等性
qiita.com/hankehly > PUTとPOSTどっち使う?
PUT INSERT INTO articles (id, name, author) VALUES (12, "foo",
"tanaka") ON CONFLICT (id) DO UPDATE SET name = "foo", author = "tanaka" PUTリクエストをSQLに例えたら qiita.com/hankehly > PUTとPOSTどっち使う?
PUT INSERT INTO articles (id, name, author) VALUES (12, "foo",
"tanaka") ON CONFLICT (id) DO UPDATE SET name = "foo", author = "tanaka" PUT /articles/12 HTTP/1.1 { "name": "foo", "author": "tanaka" } PUTリクエストをSQLに例えたら qiita.com/hankehly > PUTとPOSTどっち使う?
• PUTとPOSTの違いはリクエストデータ意図です • POSTは、1つの決まった使い方がなく、汎用的に活用できる ◦ 何かを「新規作成」するためによく使われる • PUTは、リソースの状態を丸ごと置き換える • 違いを意識することで、より表現力の高い
API 開発ができる まとめ qiita.com/hankehly > PUTとPOSTどっち使う? POST /articles/12 意図が曖昧(何するの?) PUT /articles/12 意図が明確になる
ご清聴ありがとうございます qiita.com/hankehly > PUTとPOSTどっち使う?