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
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
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.5k
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
660
About Integrant
ayato0211
0
600
Muscle Assert
ayato0211
0
320
Clojureを用いたWebアプリケーション開発
ayato0211
2
3.2k
Other Decks in Programming
See All in Programming
ECR拡張スキャンでSBOMを収集して サプライチェーン攻撃の影響調査を 爆速で終わらせてみた
akihisaikeda
1
130
Structured Concurrency, Scoped Values and Joiners in the JDK 25 26 27
josepaumard
1
150
書籍「ユーザーストーリーマッピング」が私のバイブル
asumikam
4
490
Oxlintはいかにしてtsgolintのlint ruleを呼び出しているのか
syumai
0
240
柔軟なPDFレイアウトエディタを支える型システム設計 — Discriminated UnionとConditional Typeの実践
minako__ph
1
130
TSKaigi2026-静的解析への投資がAI時代のコード品質を支える ── カスタムESLintルールの設計と運用
hayatokudou
2
170
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
520
空間オーディオの活用
objectiveaudio
0
150
GitHubCopilotCLIをはじめよう.pdf
htkym
0
340
Firefoxにコントリビューションして得られた学び
ken7253
2
160
UaaL×Androidアプリのメモリ計測 — Memory Profilerの先へ
rio432
0
160
AIベース静的検査器の偽陽性率を抑える工夫3選
orgachem
PRO
4
460
Featured
See All Featured
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.8k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
1.9k
Heart Work Chapter 1 - Part 1
lfama
PRO
7
36k
Making the Leap to Tech Lead
cromwellryan
135
9.8k
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
5.8k
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
240
Exploring anti-patterns in Rails
aemeredith
3
360
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
180
Being A Developer After 40
akosma
91
590k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
550
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.3k
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