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
0
180
MiddlewarePattern.pdf
ayato
September 11, 2015
Tweet
Share
More Decks by ayato
See All by ayato
Clojureという言語が私逹にもたらしたもの
ayato0211
6
3k
3年間考え続けてきたWebアプリケーションにおけるテストの話
ayato0211
3
240
Re:REPL-Driven Development
ayato0211
3
1.3k
Meta Template Engine
ayato0211
2
1.1k
超変換! Hiccup data structure!!
ayato0211
2
580
About Integrant
ayato0211
0
530
Muscle Assert
ayato0211
0
250
Clojureを用いたWebアプリケーション開発
ayato0211
2
3.1k
翻訳にまつわるエトセトラ
ayato0211
6
1.2k
Other Decks in Programming
See All in Programming
VitestのIn-Source Testingが便利
taro28
8
2.4k
Orleans + Sekiban + SignalR でリアルタイムWeb作ってみた
tomohisa
0
230
インプロセスQAにおいて大事にしていること / In-process QA Meetup
medley
0
140
AIコーディングエージェントを 「使いこなす」ための実践知と現在地 in ログラス / How to Use AI Coding Agent in Loglass
rkaga
4
1.2k
Browser and UI #2 HTML/ARIA
ken7253
2
170
Beyond_the_Prompt__Evaluating__Testing__and_Securing_LLM_Applications.pdf
meteatamel
0
110
UMAPをざっくりと理解 / Overview of UMAP
kaityo256
PRO
3
1.4k
ASP.NETアプリケーションのモダナイゼーションについて
tomokusaba
0
240
generative-ai-use-cases(GenU)の推しポイント ~2025年4月版~
hideg
1
380
ぽちぽち選択するだけでOSSを読めるVSCode拡張機能
ymbigo
3
1.6k
Enterprise Web App. Development (1): Build Tool Training Ver. 5
knakagawa
1
120
設計の本質:コード、システム、そして組織へ / The Essence of Design: To Code, Systems, and Organizations
nrslib
10
3.7k
Featured
See All Featured
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
331
21k
Optimising Largest Contentful Paint
csswizardry
37
3.2k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
45
9.5k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
13
830
Music & Morning Musume
bryan
47
6.5k
Stop Working from a Prison Cell
hatefulcrawdad
268
20k
Building a Modern Day E-commerce SEO Strategy
aleyda
40
7.2k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
19
1.2k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.3k
Gamification - CAS2011
davidbonilla
81
5.3k
Fireside Chat
paigeccino
37
3.4k
Rails Girls Zürich Keynote
gr2m
94
13k
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