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
3k
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.5k
Other Decks in Programming
See All in Programming
20250808_AIAgent勉強会_ClaudeCodeデータ分析の実運用〜競馬を題材に回収率100%の先を目指すメソッドとは〜
kkakeru
0
210
フロントエンドのmonorepo化と責務分離のリアーキテクト
kajitack
2
140
オープンセミナー2025@広島LT技術ブログを続けるには
satoshi256kbyte
0
130
CSC305 Summer Lecture 12
javiergs
PRO
0
130
自作OSでDOOMを動かしてみた
zakki0925224
1
1.4k
AIエージェント開発、DevOps and LLMOps
ymd65536
1
350
Oracle Database Technology Night 92 Database Connection control FAN-AC
oracle4engineer
PRO
1
210
なぜ今、Terraformの本を書いたのか? - 著者陣に聞く!『Terraformではじめる実践IaC』登壇資料
fufuhu
4
660
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
180
私の後悔をAWS DMSで解決した話
hiramax
4
140
物語を動かす行動"量" #エンジニアニメ
konifar
14
5.5k
画像コンペでのベースラインモデルの育て方
tattaka
3
1.9k
Featured
See All Featured
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
139
34k
Building Applications with DynamoDB
mza
96
6.6k
Thoughts on Productivity
jonyablonski
69
4.8k
Embracing the Ebb and Flow
colly
87
4.8k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.5k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.4k
Automating Front-end Workflow
addyosmani
1370
200k
KATA
mclloyd
32
14k
Designing Experiences People Love
moore
142
24k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
Stop Working from a Prison Cell
hatefulcrawdad
271
21k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
50k
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?