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
Rails 5 で作る RESTful API 速習会 / Rails RESTful API
Search
Altech
April 19, 2017
Programming
5
1.1k
Rails 5 で作る RESTful API 速習会 / Rails RESTful API
https://wantedly.connpass.com/event/55138/
https://github.com/Altech/rails-restful-api/pulls
Altech
April 19, 2017
Tweet
Share
More Decks by Altech
See All by Altech
継続的なサービス発展を支えるアーキテクチャと技術 / Developers Summit 2023
altech
20
6k
Wantedly の技術とアーキテクチャ / 2023年度 新人研修
altech
2
620
技術を的に当てる技術について - GraphQL を入れ直した話 / 吉祥寺.pm28
altech
7
5.9k
マイクロサービス・アーキテクチャと共存する Ruby on Rails のアーキテクチャ的拡張 - その事例と可能性 / Kaigi on Rails 2021
altech
8
3.2k
ソフトウェア設計の Why & What & How / Wantedly 新卒研修
altech
0
11k
Data-Driven Service-Oriented Architecture & UI
altech
3
1.5k
Ruby で作るデータ分析基盤
altech
9
1.9k
Object-Oriented Abstraction of Redis Sorted Set
altech
2
2.4k
Microservices on “Rails” - Wantedly のマイクロサービス事例
altech
8
5.6k
Other Decks in Programming
See All in Programming
Effective Signals in Angular 19+: Rules and Helpers @ngbe2024
manfredsteyer
PRO
0
140
モバイルアプリにおける自動テストの導入戦略
ostk0069
0
110
命名をリントする
chiroruxx
1
410
Jakarta EE meets AI
ivargrimstad
0
250
Keeping it Ruby: Why Your Product Needs a Ruby SDK - RubyWorld 2024
envek
0
190
生成AIでGitHubソースコード取得して仕様書を作成
shukob
0
430
create_tableをしただけなのに〜囚われのuuid編〜
daisukeshinoku
0
250
SymfonyCon Vienna 2025: Twig, still relevant in 2025?
fabpot
3
1.2k
Stackless и stackful? Корутины и асинхронность в Go
lamodatech
0
760
17年周年のWebアプリケーションにTanStack Queryを導入する / Implementing TanStack Query in a 17th Anniversary Web Application
saitolume
0
250
バグを見つけた?それAppleに直してもらおう!
uetyo
0
180
競技プログラミングへのお誘い@阪大BOOSTセミナー
kotamanegi
0
360
Featured
See All Featured
A Tale of Four Properties
chriscoyier
157
23k
Intergalactic Javascript Robots from Outer Space
tanoku
270
27k
The Cost Of JavaScript in 2023
addyosmani
45
7k
A Philosophy of Restraint
colly
203
16k
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.5k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.5k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
29
2k
The World Runs on Bad Software
bkeepers
PRO
65
11k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
44
9.3k
Become a Pro
speakerdeck
PRO
26
5k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.7k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
Transcript
ฏʗSOHEI TAKENO Rails 5 Ͱ࡞Δ RESTful API शձ api/v2
शձ 2017/04
γΰτͰίίϩΦυϧ • ࣗݾհ • ಋೖഎܠ • ϓϩτίϧ • ج൫࣮ •
࣮ફʢ45minʣ ϝχϡʔ
γΰτͰίίϩΦυϧ ࣗݾհ
γΰτͰίίϩΦυϧ • Sohei Takeno / @Altech_2015 • 20164݄ʹ Wantedly ʹΤϯδχΞͱͯ͠ೖࣾ
• Wantedy Visit ʹؔΘ͍ͬͯΔ • άϩʔε ― Push௨ϝʔϧͷσβΠϯվળɾνϡʔχϯάɺͦͷଞ UI ςετ • αʔϏε։ൃج൫ͷඋ ― BigQuery ಋೖ, σʔλղੳδϣϒγεςϜɺPush௨ج൫ • Ϛονϯάվળ ― ืूΛ୳͢ػೳʢϑΟϧλɾݕࡧʣͷϩδοΫˍUIվળ • ωΠςΟϒΞϓϦ͚ͷ API ࡞ ࣗݾհ
γΰτͰίίϩΦυϧ ৽͍͠APIͷಋೖഎܠ
γΰτͰίίϩΦυϧ • api/v1 ͱ͍͏ API namespace ͕ݩʑ͋ͬͨ • ը໘ͱAPI͕ີ݁߹͍ͯͨ͠ʢ؇͍ 1screen
- 1 request ํࣜʣ • දࣔΛॏࢹ • ɿ • νʔϜߏͷมԽʹґΔɺը໘ͱີ݁߹ʹىҼ͢Δੜ࢈ੑԼ • ϓϩτίϧ͕ͳ͍ʢϨεϙϯεͷܗࣜΛͲ͏͢Δ͔Λຖճ֬ೝʣ ಈػ
γΰτͰίίϩΦυϧ • RESTful ͳ API ʹΞʔΩςΫνϟΛมߋ • ϓϩτίϧͷنఆ • →
api/v2 ͱͯ͠࡞ • ʢɿ௨ৗͷόʔδϣχϯάతͳ͍ํͱҟͳΔʣ ղܾํ๏
γΰτͰίίϩΦυϧ • νʔϜͷϓϥοτϑΥʔϜ͝ͱͷ୲ํ๏ • Web ͱΞϓϦͷϓϩάϥϚҰக͢Δͷ͔ɺ͠ͳ͍ͷ͔ • νʔϜͷαʔϏε։ൃͷମ੍ • ผʑʹػೳΛ࣮͍ͯ͘͠ͷ͔ɺ౷Ұͯ͠ਐΊ͍ͯ͘ͷ͔ɺWeb
͕ઌߦ͢Δͷ͔ɺΞϓϦ͕ઌߦ͢Δͷ͔ • ϢʔβʔʢiOS, Android ϓϩάϥϚʣͷϦςϥγʔ • ΫϥΠΞϯτʢiOS ΞϓϦ, Android ΞϓϦʣͷઃܭ • ΞʔΩςΫνϟʁViewModel Έ͍ͨͳͷΛೖΕΔ͜ͱՄೳ͔ʁ • ͳͲ… લఏɿRESTful ͔ͩΒྑ͍Θ͚Ͱͳ͍ API ͷΞʔΩςΫνϟΛܾఆ͢Δࡍʹґଘͨ͜͠ͱͷྫɿ
γΰτͰίίϩΦυϧ v1 ࡞࣌
γΰτͰίίϩΦυϧ • Wantedly Visit ॳͷ iOS ΞϓϦϦϦʔε • ಉ͡ҰਓͷϓϩάϥϚ͕ iOS
Web ॻ͘ • Server-Client = 1 : 1 v1࡞࣌ͷ։ൃମ੍ʢ2014/5ʣ
γΰτͰίίϩΦυϧ • Web, iOS, Android ͦΕͧΕҰਓʢUser Growth νʔϜʣ • Web
Web Ͱ iterative ʹϦϦʔεɾݕূͯ͠αʔϏε վળΛ͍ͯ͘͠ͷ͕ϝΠϯλεΫ • Web ͕ઌߦ͢Δ։ൃͳͷͰ API Λॻ࣌͘Ϟσϧ͋Δఔ Ͱ͖͍ͯΔঢ়ଶ • ʢͪͳΈʹݱࡏ Web, iOS ͱʹೋਓʹʣ v2࡞࣌ͷ։ൃମ੍ʢ2017/1ʣ
γΰτͰίίϩΦυϧ • ը໘ͷৄࡉʹ͍͍ͪͪ Web ͷΤϯδχΞ͕͍ؔͯͯ͠ੜ࢈ੑ͕Լ͕Δ • มߋͷࡍɺطʹ͋Δը໘ͷ͕ࣝલఏʹͳΔͷͰɺ͍͠ • ίϛϡχέʔγϣϯͷ༰͕σʔλʹϑΥʔΧε͞ΕΔ •
ϞσϧʹରԠͯ͠ΤϯυϙΠϯτͱίϯτϩʔϥΛ࡞͍ͬͯ͘ͷͰɺมߋ ͖͢Օॴ͕໌֬ • ઃܭʹ੍͕ՃΘΔͷͰɺΑΓͦ͜ʹϑΥʔΧε͍͍ͨ͢͠ϓϩτί ϧϥΠϒϥϦΛಋೖͰ͖ΔΑ͏ʹͳΔ ಋೖഎܠ·ͱΊ api/v2 ͷಋೖ
γΰτͰίίϩΦυϧ ϓϩτίϧ
https://github.com/Altech/rails-restful-api/blob/master/README.md
γΰτͰίίϩΦυϧ ج൘࣮
γΰτͰίίϩΦυϧ • ActiveModelSerializers ΛϦΫΤετύϥϝʔλͱͭͳ͙ • N+1 ΛγεςϚςΟοΫʹ͙Έ • ad-hoc ύϥϝʔλΛϢʔβʔʹ͑Δํ๏
• ίʔυɿPull Requests · Altech/rails-restful-api ඞཁͩͬͨج൫࣮
γΰτͰίίϩΦυϧ ࣮ફ
γΰτͰίίϩΦυϧ • Wantedly Visit ͷձࣾը໘ͷAPIΛ࡞Δ • Ұॹʹॻ͍͍͖ͯ·͢ʂ श༰
None
γΰτͰίίϩΦυϧ • ɿhttps://github.com/Altech/rails-restful-api/pull/7
γΰτͰίίϩΦυϧ ͋Γ͕ͱ͏͍͟͝·ͨ͠ɻ