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
Reitit使ってみた
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
valerauko
November 29, 2018
Programming
400
0
Share
Reitit使ってみた
ClojureのルーティングライブラリReititを使っての感想などのお話
valerauko
November 29, 2018
More Decks by valerauko
See All by valerauko
CIにどこまで任せるのか?
valerauko
0
240
分解に救われる
valerauko
0
110
Other Decks in Programming
See All in Programming
VueエンジニアがReactを触って感じた_設計の違い
koukimiura
0
190
Offline should be the norm: building local-first apps with CRDTs & Kotlin Multiplatform
renaudmathieu
0
230
ハーネスエンジニアリングにどう向き合うか 〜ルールファイルを超えて開発プロセスを設計する〜 / How to approach harness engineering
rkaga
24
15k
AIと共に生きる技術選定 2026
sgash708
0
110
「Linuxサーバー構築標準教科書」を読んでみた #ツナギメオフライン.7
akase244
0
1.4k
The Monolith Strikes Back: Why AI Agents ❤️ Rails Monoliths
serradura
0
350
t *testing.T は どこからやってくるの?
otakakot
1
760
Claude Codeをカスタムして自分だけのClaude Codeを作ろう
terisuke
0
150
YJITとZJITにはイカなる違いがあるのか?
nakiym
0
250
mruby on C#: From VM Implementation to Game Scripting (RubyKaigi 2026)
hadashia
2
750
From Formal Specification to Property Based Test
ohbarye
0
390
瑠璃の宝石に学ぶ技術の声の聴き方 / 【劇場版】アニメから得た学びを発表会2026 #エンジニアニメ
mazrean
0
300
Featured
See All Featured
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
1
3.6k
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
730
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
200
Unsuck your backbone
ammeep
672
58k
Exploring anti-patterns in Rails
aemeredith
3
330
Mind Mapping
helmedeiros
PRO
1
170
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
0
260
The Spectacular Lies of Maps
axbom
PRO
1
710
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.2k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.2k
Building Adaptive Systems
keathley
44
3k
Transcript
Reitit使ってみた エル [valerauko]
Reititはルーティング用のライブラリ • フィンランド語で「ルート」 • ringのmiddlewareやpedestalのinterceptorも使える • Compojureとかをすごく意識してる • ルートはデータ •
API用の便利機能が豊富 • かなり速い
ルートがデータ? ["/.well-known" {:summary "WebFinger endpoints" :swagger {:tags ["WebFinger"]}} ["/host-meta" {:get
{:summary "Host metadata" :swagger {:produces #{"application/xrd+xml" "application/xml"}} :responses {200 {:body any?}} :handler host-meta}}] ["/webfinger" {:get {:summary "WebFinger endpoint for users" :swagger {:produces #{"application/xrd+xml" "application/jrd+json"}} :parameters {:query {:resource ::spec/resource}} :responses {200 {:body any?}} :handler resource}}]]
なんで速いのか • ルートがただのデータでコンパイル時に完結する ◦ なおルートのバッティングを許さない前提 • フラットなデータ構造体になるので「検索」が速い • OKのレスポンス(ルートがある)に最適化されてる ◦
/hello -> /hello/みたいなリダイレクトとか ◦ 存在しないルートとかは別に扱われる
引っかかりそうなところ • ルートのコンパイル時、ミドルウェアがルートにいちいちコピーされる ◦ PRO 探さなくて済むから速いのは速い ◦ CON 何かの共通の状態(ステート)があるとバグる •
考えずにringのdefault-middleware付けてもセッションが動かない ◦ 関数だけルートにコピーされて、それぞれ共有されない session-store作ってしまう ◦ 開発者いわく「interceptorなら動くはず」とのこと • middlewareの関数はモックできない ◦ with-redefsしても、すでにルートにコピーされてるから置き換えられない
便利機能 • ルートに任意のデータも紐付けられる ◦ {:role #{:roles/admin}}みたいにエンドポイントに必要な権限 ◦ ミドルウェアやハンドラで確認に使える • swagger対応
◦ API開発ならものすごく便利 ◦ UIまであるので手でcurl打たなくて済む • coercion (形式強制) ◦ リクエストもレスポンスも形式が定義できる ◦ clojure.spec, schema, metosin製のdata-spec ◦ middleware入れると形に合ってないの弾く
参考文献 • https://github.com/metosin/reitit • Clojurians #reitit • https://github.com/valerauko