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
MiddlewarePattern.pdf
Search
ayato
September 11, 2015
Programming
200
0
Share
MiddlewarePattern.pdf
ayato
September 11, 2015
More Decks by ayato
See All by ayato
マイクロサービス内で動くAPIをF#で書いている
ayato0211
1
1.4k
Clojureという言語が私逹にもたらしたもの
ayato0211
6
3.2k
3年間考え続けてきたWebアプリケーションにおけるテストの話
ayato0211
3
300
Re:REPL-Driven Development
ayato0211
3
1.4k
Meta Template Engine
ayato0211
2
1.2k
超変換! Hiccup data structure!!
ayato0211
2
650
About Integrant
ayato0211
0
590
Muscle Assert
ayato0211
0
310
Clojureを用いたWebアプリケーション開発
ayato0211
2
3.2k
Other Decks in Programming
See All in Programming
レガシーPHP転生 〜父がドメインエキスパートだったのでDDD+Claude Codeでチート開発します〜
panda_program
0
1.1k
実用!Hono RPC2026
yodaka
2
270
YJITとZJITにはイカなる違いがあるのか?
nakiym
0
250
ドメインイベントでビジネスロジックを解きほぐす #phpcon_odawara
kajitack
3
810
Swift Concurrency Type System
inamiy
1
550
アーキテクチャモダナイゼーションとは何か
nwiizo
19
5.5k
GNU Makeの使い方 / How to use GNU Make
kaityo256
PRO
16
5.6k
AIと共に生きる技術選定 2026
sgash708
0
110
第3木曜LT会 #28
tinykitten
PRO
0
110
HTML-Aware ERB: The Path to Reactive Rendering @ RubyKaigi 2026, Hakodate, Japan
marcoroth
0
290
エラー処理の温故知新 / history of error handling technic
ryotanakaya
6
1.6k
AI-DLC Deep Dive
yuukiyo
9
4.8k
Featured
See All Featured
Scaling GitHub
holman
464
140k
Information Architects: The Missing Link in Design Systems
soysaucechin
0
900
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
1
530
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
110
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
750
Evolving SEO for Evolving Search Engines
ryanjones
0
180
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
280
Code Reviewing Like a Champion
maltzj
528
40k
The Art of Programming - Codeland 2020
erikaheidi
57
14k
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
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
210
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