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
GoでWeb APIを作る - JSON Hyper-Schemaからいろいろ生成する
Search
tutuming
August 24, 2015
Programming
16
2.9k
GoでWeb APIを作る - JSON Hyper-Schemaからいろいろ生成する
2015.08.24 リブセンス様社内勉強会LT資料
tutuming
August 24, 2015
Tweet
Share
More Decks by tutuming
See All by tutuming
NSQのご紹介
tutuming
1
1.4k
Other Decks in Programming
See All in Programming
R言語の環境構築と基礎 Tokyo.R 112
bob3bob3
0
270
VSCodeでのDatabricks開発もお勧めしたい/I would also recommend Databricks development with VSCode.
kazumain
0
260
Netty Chicago Java User Group 2024-04-17
sullis
0
180
スクラムガイドのスプリントレトロスペクティブを改めて読みかえしてみた / Re-reading the Sprint Retrospective Section in the Scrum Guide
mackey0225
3
430
ONE WEDGE_company_guide
1wedge_one
0
490
try! Swift Tokyo 初参加報告LT
hinakko2
0
220
0→1と1→10の狭間で Javaという技術選定を振り返る/Reflecting on the Decision to Choose Java Between Scaling from 0 to 1 and 1 to 10
jaguar_imo
2
380
VS Code をプロダクトにどう取り込むか
onomax
1
370
Ruby Function Composition
bkuhlmann
1
330
if constexpr文はテンプレート世界のラムダ式である
faithandbrave
3
650
StoreKit2によるiOSのアプリ内課金のリニューアル
kangnux
0
110
What We Can Learn From OSS
inouehi
0
420
Featured
See All Featured
Designing for Performance
lara
601
67k
Statistics for Hackers
jakevdp
789
220k
Mobile First: as difficult as doing things right
swwweet
216
8.6k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
357
22k
The Pragmatic Product Professional
lauravandoore
25
5.8k
Building Your Own Lightsaber
phodgson
99
5.7k
Put a Button on it: Removing Barriers to Going Fast.
kastner
58
3.1k
Building Better People: How to give real-time feedback that sticks.
wjessup
355
18k
It's Worth the Effort
3n
180
27k
Fireside Chat
paigeccino
21
2.6k
Making the Leap to Tech Lead
cromwellryan
124
8.5k
Agile that works and the tools we love
rasmusluckow
325
20k
Transcript
GoͰWeb APIΛ࡞Δ JSON Hyper-Schema͔Β͍Ζ͍Ζੜ͢Δ @tutuming
ࣗݾհ • แ • @tutuming • גࣜձࣾ WACUL CTO
We are hiring!
ԿΛ࡞͍ͬͯΔ͔ • AIΞφϦετ • Google Analytics ࿈ܞ • ࣗಈղੳ •
αΠτͷ՝Λݟ͚ͭΔ We are hiring!
AIΞφϦετͷߏ • όοΫΤϯυ Go, MongoDB, Elasticsearch • ϑϩϯτΤϯυ TypeScript (CoffeeScript)
, AngularJS
Go ͬͯΔਓ !?
ࠓ͍͑ͨ͜ͱ REST API ΛGoͰ։ൃ͢Δͱ͖ • APIυΩϡϝϯτ • ܕఆٛ • όϦσʔγϣϯ
• ϋϯυϥͷͻͳܗ ͍Ζ͍Ζࣗಈੜ͢ΔͱḿΔΑ
Why Go? • εέʔϧ͢ΔΈ -> gorutine, channel • ੩తܕ͚ ->
มߋʹର͢Δ҆৺ײ • ίϯύΠϧҰॠ -> εΫϦϓτݴޠΈ͍ͨʹಈ͔ͤΔ • ϘτϜΞοϓͷจԽ
REST API with Go ΠϯλʔϑΣΠε(JSONͱͷϚοϐϯά)ఆٛͷͭΒΈ map[string]interface{} // ͓खܰ <-> ܕͷϝϦοτͳ͠
struct ఆٛ // ݎ࿚ <-> खͰॻ͘ͷ͠ΜͲ͍
ੜͨ͠Β͑͑Μ • JSON Hyper-Schema • http://json-schema.org/latest/json-schema- hypermedia.html • JSONͷܕఆٛɺόϦσʔγϣϯఆٛ •
+ Http্ͷϦιʔεఆٛ = REST ͜ΕͰʂ
͡ΌʔΜ schema.json ॻ͘ͷͭΒͨΜ 1ϑΝΠϧ 4000ߦ
prmd by heroku • https://github.com/interagent/prmd • YAMLͰ ෳϑΝΠϧʹ͚ͯཧͰ͖Δ • ->
1ͭͷschema.json ʹcombine • schema.json ͔Β υΩϡϝϯτੜͰ͖Δ
શମߏ
JSON ܕఆٛ
Go struct ੜ
Validator ੜ https://github.com/wcl48/valval
Ϧιʔεఆٛ
endpoint Έੜ ্ͷؔΛड͚औͬͯ ύϥϝʔλͷόϦσʔγϣϯ JSONͷੜͳͲΛߦ͏ॲཧΛroterʹઃఆ // GETύϥϝʔλ // PaymentͷϦετΛฦ͢
APIมߋϑϩʔ • YAMLॻ͘ • ఆٛɾυΩϡϝϯτੜ • ίϯύΠϧΤϥʔ͢ • ϩδοΫ࣮ •
ςετॻ͘
ར༻ऀͷ • υοτΛଧͬͨΒิ͕ग़ΔͷͰɺ伳ḜԌ͕࣏Γ·ͨ͠ (29ࡀ உੑ) • ܕ͕͋ΔͱϦϦʔεޙ҆৺ͯ͠Ε·͢ (29ࡀ உੑ) •
υΩϡϝϯτͱ࣮͕ҧ͏ͬͯԥΒΕͳ͘ͳͬͨ (29ࡀ உੑ) • ੜࣦഊͨ͠ͱ͖ͷΤϥʔ͕Θ͔Γʹ͍͘ (29ࡀ உੑ)
·ͱΊ • Go ྑ͍ݴޠ ͚ͩͲ • Web API ࡞Δͱ͖ɺJSONͷܕఆٛͭΒ͍ •
ಛʹϦϦʔεޙมߋଟ͍ • JSON Hyper-Schema Λ prmd ͳͲͷิॿπʔϧͰੜͯ͠ • υΩϡϝϯτɺܕఆٛɺόϦσʔλɺϋϯυϥͷͻͳܗΛੜ͢Δ ͱ • ͱͯޮతɺݎ࿚ͳ։ൃαΠΫϧ͕Ͱ͖͕͋ΔͷͰ͓͢͢Ί
Thank you! Any questions?