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
URLルーティングをつくるエピソード1
Search
bmf_san
December 19, 2018
Programming
340
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
URLルーティングをつくるエピソード1
bmf_san
December 19, 2018
More Decks by bmf_san
See All by bmf_san
桃太郎で始めるRego入門‐今日から使えるRegoの基本編
bmf_san
0
110
完璧を求めない意思決定-アクセス制御基盤における制約との向き合い方
bmf_san
5
20k
AAPについて調べてみた
bmf_san
0
160
レーダーをつくる
bmf_san
0
97
契約テストとPactについて
bmf_san
0
140
5分でわかるSLO
bmf_san
2
190
権限について考える
bmf_san
2
190
自作HTTPルーターから新しいServeMuxへ
bmf_san
3
1.9k
古くなってしまったPHPフレームワークとPHPのバージョンアップ戦略
bmf_san
1
530
Other Decks in Programming
See All in Programming
なぜCTOを降りてFDEを選んだのか?〜なぜプロダクト企業がFDEで顧客の現場に踏み込むのか〜
gonta
1
210
Rでドレミ/Do-Re-Mi_with_R
florets1
0
130
FactoryBotをやめればRSpecは速くなるのか?
yuta_onishi_97
0
600
Starting & Sustaining Code-Based E2E Testing for Non-Coding QA Teams( #jasstniigata )
teyamagu
PRO
1
1k
全ての永続トークンを、生まれる前に消し去りたい!
sylph01
2
940
Railsバージョンを4倍にした話
optim
0
420
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
1
750
Workers Cache を知る
syumai
0
370
作れる、でも消せるか?──安全に「枯らして消す」機能削除術 / Drain, Then Delete
chobishiba
2
740
UnityでSystem.Net.WebSocketsなWebSocketサーバが動かないのでUnity Monoのコードを覗いてみた / about implementing websocket server with unity mono
drumath2237
1
610
3回つくってわかった、 定期実行ジョブ基盤の本質情報
takai
0
500
contenteditable と日本語入力に向き合う
colorful12
0
200
Featured
See All Featured
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
330
For a Future-Friendly Web
brad_frost
184
10k
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
530
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.7k
Reflections from 52 weeks, 52 projects
jeffersonlam
356
22k
Visualization
eitanlees
153
17k
Skip the Path - Find Your Career Trail
mkilby
1
260
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
800
How GitHub (no longer) Works
holman
316
150k
What the history of the web can teach us about the future of AI
inesmontani
PRO
2
740
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.6k
Music & Morning Musume
bryan
48
7.4k
Transcript
URLルーティングをつくる エピソード1 @Makuake LT Party 2018/12/19
動機 ・ある⽇Golangを触っていた ・「標準ライブラリが充実していていいなぁ」 ・「でもnet/httpのURLパースはちょっと弱いから外 部ライブラリ使うのがスタンダートかな・・?」 ・「⾃分で⽤意したい!」
URLルーティングとは? ・リクエストされるURLに対し、実⾏したい処理は何 かを判定させるもの • ex. http://example.com/users • /users → UserControllerͷॲཧΛฦ͢
実装パターン ・正規表現でURLマッチング ・⽊構造を⽤いて⽂字列探索のアルゴリズムを使う
⽊構造とは? ・グラフ理論という数学の分野で定義されている⽊の 構造を持つデータ構造のこと ・⽊ ・複数の点(nodeまたはvertex)と複数の辺 (edge)で構成されたグラフ
ɹࠜʢSPPUʣ ɹࢬʢFEHFʣ ɹઅʢOPEFʣ ɹ༿ʢMFBGʣ
⽊構造の例 ・家系図 ・ファイルシステム ・ドメイン名(cf. https://www.nic.ad.jp/ja/dom/system.html) ・構⽂⽊ ・コンパイラ ・DOMツリー ・親⼦構造を持つタグやカテゴリとか
参考になりそうな実装を⾒てみる ・https://gist.github.com/neo-nanikaka/ c2e2f7742b311696d50b ・https://github.com/nissy/bon ・https://github.com/nissy/mux ・https://github.com/ytakano/radix_tree ・https://github.com/kkdai/radix ・https://github.com/MarkBaker/Tries
なるほどわからん
URLルーティングをつくる ・何を⽊構造として扱うか? ・→ルート定義のリスト ・実装の流れ ・インプットとして、ルート定義とURLパスを得る ・ルート定義から⽊構造を⽣成 ・URLパスをターゲットとして⽊構造を探索、マッチしたデー タを返す
None
1BUI .FUIPE "DUJPO (&5 )PNF$POUSPMMFS!EP4PNF"DUJPO VTFST (&5 6TFS$POUSPMMFS!EP4PNF"DUJPO VTFSTVTFS@JE
(&5 6TFS$POUSPMMFS!EP4PNF"DUJPO VTFSTVTFS@JE 1045 6TFS$POUSPMMFS!EP4PNF"DUJPO VTFSTFWFOUT (&5 6TFS$POUSPMMFS!EP4PNF"DUJPO VTFSTFWFOU@JE (&5 6TFS$POUSPMMFS!EP4PNF"DUJPO VTFSTFWFOU@JE 1045 6TFS$POUSPMMFS!EP4PNF"DUJPO VTFSTTVQQPSU (&5 6TFS$POUSPMMFS!EP4PNF"DUJPO
VTFST (&5 VTFS@JE TVQQPSU FWFOU@JE (&5
(&5 (&5 (&5 1045 )551෦͕ऴϊʔυʢ༿ʣʹͳΔ
None
To be continued