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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
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.3k
Clojureという言語が私逹にもたらしたもの
ayato0211
6
3.1k
3年間考え続けてきたWebアプリケーションにおけるテストの話
ayato0211
3
290
Re:REPL-Driven Development
ayato0211
3
1.3k
Meta Template Engine
ayato0211
2
1.2k
超変換! Hiccup data structure!!
ayato0211
2
640
About Integrant
ayato0211
0
590
Muscle Assert
ayato0211
0
300
Clojureを用いたWebアプリケーション開発
ayato0211
2
3.2k
Other Decks in Programming
See All in Programming
AI巻き込み型コードレビューのススメ
nealle
2
2.4k
浮動小数の比較について
kishikawakatsumi
0
360
エージェント開発初心者の僕がエージェントを作った話と今後やりたいこと
thasu0123
0
220
PostgreSQL を使った快適な go test 環境を求めて
otakakot
0
370
Event Storming
hschwentner
3
1.3k
AWS Infrastructure as Code の新機能 2025 総まとめ 〜SA 4人による怒涛のデモ祭り〜
konokenj
10
2.8k
ぼくの開発環境2026
yuzneri
1
290
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
310
AI時代のソフトウェア開発でも「人が仕様を書く」から始めよう-医療IT現場での実践とこれから
koukimiura
0
110
PJのドキュメントを全部Git管理にしたら、一番喜んだのはAIだった
nanaism
0
220
オブザーバビリティ駆動開発って実際どうなの?
yohfee
2
630
AIによる高速開発をどう制御するか? ガードレール設置で開発速度と品質を両立させたチームの事例
tonkotsuboy_com
7
2.6k
Featured
See All Featured
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
63
53k
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
190
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
55
3.3k
AI: The stuff that nobody shows you
jnunemaker
PRO
3
340
A better future with KSS
kneath
240
18k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
2.8k
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.2k
Abbi's Birthday
coloredviolet
2
5k
[RailsConf 2023] Rails as a piece of cake
palkan
59
6.3k
From π to Pie charts
rasagy
0
140
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
850
Joys of Absence: A Defence of Solitary Play
codingconduct
1
300
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