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
感情を設計する
ichimichi
5
1.5k
検索設計から 推論設計への重心移動と Recall-First Retrieval
po3rin
3
1k
GitHubCopilotCLIをはじめよう.pdf
htkym
0
250
Claude Codeをカスタムして自分だけのClaude Codeを作ろう
terisuke
0
140
🦞OpenClaw works with AWS
licux
1
220
ハーネスエンジニアリングにどう向き合うか 〜ルールファイルを超えて開発プロセスを設計する〜 / How to approach harness engineering
rkaga
24
14k
HTML-Aware ERB: The Path to Reactive Rendering @ RubyKaigi 2026, Hakodate, Japan
marcoroth
0
180
GNU Makeの使い方 / How to use GNU Make
kaityo256
PRO
16
5.6k
ハーネスエンジニアリングとは?
kinopeee
12
6k
Server-Side Kotlin LT大会 vol.18 [Kotlin-lspの最新情報と Neovimのlsp設定例]
yasunori0418
1
180
Liberating Ruby's Parser from Lexer Hacks
ydah
2
2k
事業会社でのセキュリティ長期インターンについて
masachikaura
0
260
Featured
See All Featured
How Software Deployment tools have changed in the past 20 years
geshan
0
33k
Building the Perfect Custom Keyboard
takai
2
740
HDC tutorial
michielstock
2
630
Ruling the World: When Life Gets Gamed
codingconduct
0
210
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
180
Designing Experiences People Love
moore
143
24k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.8k
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
170
Being A Developer After 40
akosma
91
590k
A designer walks into a library…
pauljervisheath
211
24k
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
1
3.5k
Marketing to machines
jonoalderson
1
5.2k
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