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
マイクロサービス内で動くAPIをF#で書いている
ayato0211
1
740
Clojureという言語が私逹にもたらしたもの
ayato0211
6
3k
3年間考え続けてきたWebアプリケーションにおけるテストの話
ayato0211
3
260
Re:REPL-Driven Development
ayato0211
3
1.3k
Meta Template Engine
ayato0211
2
1.1k
超変換! Hiccup data structure!!
ayato0211
2
600
About Integrant
ayato0211
0
550
Muscle Assert
ayato0211
0
260
Clojureを用いたWebアプリケーション開発
ayato0211
2
3.1k
Other Decks in Programming
See All in Programming
ソフトウェア設計とAI技術の活用
masuda220
PRO
22
5.8k
PipeCDのプラグイン化で目指すところ
warashi
1
310
What's new in AppKit on macOS 26
1024jp
0
150
構文解析器入門
ydah
6
1.5k
オンコール⼊⾨〜ページャーが鳴る前に、あなたが備えられること〜 / Before The Pager Rings
yktakaha4
2
1k
テスト駆動Kaggle
isax1015
1
790
チームで開発し事業を加速するための"良い"設計の考え方 @ サポーターズCoLab 2025-07-08
agatan
1
480
レベル1の開発生産性向上に取り組む − 日々の作業の効率化・自動化を通じた改善活動
kesoji
1
310
Vibe Codingの幻想を超えて-生成AIを現場で使えるようにするまでの泥臭い話.ai
fumiyakume
16
8.1k
CDK引数設計道場100本ノック
badmintoncryer
2
500
Jakarta EE Meets AI
ivargrimstad
0
120
ソフトウェア品質を数字で捉える技術。事業成長を支えるシステム品質の マネジメント
takuya542
2
15k
Featured
See All Featured
What's in a price? How to price your products and services
michaelherold
246
12k
Building Applications with DynamoDB
mza
95
6.5k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
32
2.4k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
53
2.9k
A Tale of Four Properties
chriscoyier
160
23k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
130
19k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
8
700
Thoughts on Productivity
jonyablonski
69
4.7k
Mobile First: as difficult as doing things right
swwweet
223
9.7k
Code Review Best Practice
trishagee
69
19k
Building Adaptive Systems
keathley
43
2.7k
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