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
Reitit使ってみた
Search
valerauko
November 29, 2018
Programming
410
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Reitit使ってみた
ClojureのルーティングライブラリReititを使っての感想などのお話
valerauko
November 29, 2018
More Decks by valerauko
See All by valerauko
CIにどこまで任せるのか?
valerauko
0
250
分解に救われる
valerauko
0
110
Other Decks in Programming
See All in Programming
Apple Intelligenceとオンデバイス時代の到来
yahir0
0
170
baseline으로 마이그레이션, 리팩토링 안전하게 맡기기
fornewid
1
560
Next.js: The final boss of Web Performance
guaca
0
370
PyConTW 2026 - AI Coding 不只是工具升級, 區域醫院醫療資訊系統協作開發與資訊團隊轉型實踐
cclai999
0
210
Compiling a real-world CLI tool to native with Static Hermes
tmikov2023
0
140
SFCで実現する病院・医療システムの動的組み立て式UI
koukimiura
1
140
PumaからFalconに移行したRailsアプリケーションでの実践
falcon8823
0
300
3回つくってわかった、 定期実行ジョブ基盤の本質情報
takai
4
3.5k
AmebaブログはKMPから卒業します
kmars0605
0
310
Seven New Principles of Software Engineering
yegor256
0
380
Event is what happens
moro
2
2.1k
プロジェクトコードをキレイキレイしよう!暗黙的な参照を読み解く静的解析
ostk0069
0
190
Featured
See All Featured
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2.2k
Code Reviewing Like a Champion
maltzj
529
40k
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
The SEO Collaboration Effect
kristinabergwall1
1
610
A Soul's Torment
seathinner
8
3.8k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.6k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
340
RailsConf 2023
tenderlove
30
1.6k
VelocityConf: Rendering Performance Case Studies
addyosmani
331
25k
Producing Creativity
orderedlist
PRO
348
41k
A designer walks into a library…
pauljervisheath
211
25k
My Coaching Mixtape
mlcsv
0
370
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