Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
MiddlewarePattern.pdf
Search
ayato
September 11, 2015
Programming
0
190
MiddlewarePattern.pdf
ayato
September 11, 2015
Tweet
Share
More Decks by ayato
See All by ayato
マイクロサービス内で動くAPIをF#で書いている
ayato0211
1
1.1k
Clojureという言語が私逹にもたらしたもの
ayato0211
6
3.1k
3年間考え続けてきたWebアプリケーションにおけるテストの話
ayato0211
3
280
Re:REPL-Driven Development
ayato0211
3
1.3k
Meta Template Engine
ayato0211
2
1.2k
超変換! Hiccup data structure!!
ayato0211
2
630
About Integrant
ayato0211
0
570
Muscle Assert
ayato0211
0
280
Clojureを用いたWebアプリケーション開発
ayato0211
2
3.2k
Other Decks in Programming
See All in Programming
Claude Codeの「Compacting Conversation」を体感50%減! CLAUDE.md + 8 Skills で挑むコンテキスト管理術
kmurahama
1
610
「コードは上から下へ読むのが一番」と思った時に、思い出してほしい話
panda728
PRO
39
26k
tparseでgo testの出力を見やすくする
utgwkk
2
260
SwiftUIで本格音ゲー実装してみた
hypebeans
0
470
開発に寄りそう自動テストの実現
goyoki
2
1.3k
0→1 フロントエンド開発 Tips🚀 #レバテックMeetup
bengo4com
0
290
著者と進める!『AIと個人開発したくなったらまずCursorで要件定義だ!』
yasunacoffee
0
150
Cap'n Webについて
yusukebe
0
150
FluorTracer / RayTracingCamp11
kugimasa
0
240
Socio-Technical Evolution: Growing an Architecture and Its Organization for Fast Flow
cer
PRO
0
390
公共交通オープンデータ × モバイルUX 複雑な運行情報を 『直感』に変換する技術
tinykitten
PRO
0
160
堅牢なフロントエンドテスト基盤を構築するために行った取り組み
shogo4131
8
2.5k
Featured
See All Featured
Git: the NoSQL Database
bkeepers
PRO
432
66k
GraphQLの誤解/rethinking-graphql
sonatard
73
11k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.5k
Reflections from 52 weeks, 52 projects
jeffersonlam
355
21k
How GitHub (no longer) Works
holman
316
140k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.6k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
286
14k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
51k
The Power of CSS Pseudo Elements
geoffreycrofte
80
6.1k
It's Worth the Effort
3n
187
29k
YesSQL, Process and Tooling at Scale
rocio
174
15k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
400
Transcript
Middleware Pattern @_ayato_p/Cybozu Startups, Inc.
(def _ayato_p {:name "あやぴー" :lang
[:clojure :ruby :javascript] :company "Cybozu Startups, Inc."})
(def _ayato_p {:name "あやぴー" :lang
[:clojure :ruby :javascript] :company "Cybozu Startups, Inc."}) Clojure 歴、半年
Agenda Ring Ring Middleware Middleware Pattern
Ring
Ring サーバーを抽象化する仕様/デファクトスタンダード Ring Handler, Requests, Responses, Middleware 公式には
jetty のアダプタがある 最近で Ring インターフェイスを実装したものだと Immutant などがある
Ring Middleware
Ring Middleware ただの高階関数 Ring Middleware の場合、 Handler を受け取って
Request を受け取る関数を返すような書き方されてる
Ring Middleware (defn wrap-secret-key[handler secret-key] (fn [req]
(handler (assoc-in req [:params :secret-key] secret-key)))) (defn make-handler [handler] (-> handler (wrap-secret-key "This is secret!!") wrap-something wrap-anything wrap-defaults)) (app (make-handler (get-ring-handler)))
Middleware Pattern
Middleware Pattern Ring Middleware はひとつの Middleware Pattern 例 他には
Boot でも適用されている
Use case ユーザーの入力を受け取って、関数を適用するか決めたい config ファイルを使って、関数を適用するか決めたい LazySeq に適用する関数をオプションから決めたい
-> Composable な関数を作りたい!!
Conclusion Composable な関数を書くお供に Middleware Pattern を活用しよう
Enjoy Clojure