Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
PUTとPOSTどっち使う?
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Hank Ehly
June 23, 2022
Technology
1.2k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
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
680
Celeryの紹介と本番運用のTips
hankehly
0
1.7k
ChatGPTを活用した 便利ツールの紹介
hankehly
1
1.4k
Efficient Energy Analytics with Airflow, Spark, and MLFlow
hankehly
0
440
Deferrable Operators入門
hankehly
0
810
【初心者/ハンズオン】Dockerコンテナの基礎知識
hankehly
0
620
Compositeパターン: オブジェクトの階層関係をエレガントに表現する方法
hankehly
0
370
10/29 Airflowの基礎を学ぶハンズオンワークショップ
hankehly
0
340
システム/データ品質保証のための Airflow 活用法
hankehly
0
700
Other Decks in Technology
See All in Technology
日本語に強いオープンな大規模言語モデル「LLM-jp」
odashi
5
1.2k
触りたくないデータに、どう触るか AI時代のRBACアクセスガバナンス
ivry_presentationmaterials
0
290
Benchmarking Disaggregated Serving on vLLM + Dynamo with a Real Coding-Agent Workload
nttcom
1
200
Temporal 最高!でも改めて「日付」について調べたら人類の負債すぎる件
riyaamemiya
0
210
ブラウザとサーバーから考えるAI時代のフロントエンド監視
shogo4131
3
1k
価値について
gree_tech
PRO
0
110
AI導入は済んだ。次は統制を作り替える番だ_AI×開発組織 Summit 2026
techtekt
PRO
0
390
LLM-as-a-Judgeは本当に信頼できるのか――評価器を評価する話
taka_aki
1
620
Getting Started with Google Antigravity
glaforge
0
330
二歩目のフロントエンド・ウェブアクセシビリティ
camiha
2
690
SharedWorkerを使ったキャッシュでネイティブアプリに負けないユーザー体験を目指す
kakehashi
PRO
1
110
Metadata - Section 1: HTML Basics
mohab1
0
130
Featured
See All Featured
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
330
Site-Speed That Sticks
csswizardry
13
1.6k
What's in a price? How to price your products and services
michaelherold
247
13k
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.5k
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
550
Reflections from 52 weeks, 52 projects
jeffersonlam
356
22k
Building an army of robots
kneath
307
47k
Large-scale JavaScript Application Architecture
addyosmani
516
110k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.7k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
400
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
1k
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どっち使う?