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
800
Clojureという言語が私逹にもたらしたもの
ayato0211
6
3.1k
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
560
Muscle Assert
ayato0211
0
270
Clojureを用いたWebアプリケーション開発
ayato0211
2
3.1k
Other Decks in Programming
See All in Programming
マイコンでもRustのtestがしたい その2/KernelVM Tokyo 18
tnishinaga
2
1.9k
Comparing decimals in Swift Testing
417_72ki
0
170
ワープロって実は計算機で
pepepper
2
1.3k
LLMOpsのパフォーマンスを支える技術と現場で実践した改善
po3rin
6
660
変化を楽しむエンジニアリング ~ いままでとこれから ~
murajun1978
0
710
新世界の理解
koriym
0
130
Amazon Q CLI開発で学んだAIコーディングツールの使い方
licux
3
180
バイブコーディング × 設計思考
nogu66
0
110
「リーダーは意思決定する人」って本当?~ 学びを現場で活かす、リーダー4ヶ月目の試行錯誤 ~
marina1017
0
210
Infer入門
riru
4
1.4k
STUNMESH-go: Wireguard NAT穿隧工具的源起與介紹
tjjh89017
0
340
React は次の10年を生き残れるか:3つのトレンドから考える
oukayuka
41
16k
Featured
See All Featured
Intergalactic Javascript Robots from Outer Space
tanoku
272
27k
A better future with KSS
kneath
239
17k
Why You Should Never Use an ORM
jnunemaker
PRO
58
9.5k
Measuring & Analyzing Core Web Vitals
bluesmoon
8
550
The World Runs on Bad Software
bkeepers
PRO
70
11k
Building Applications with DynamoDB
mza
96
6.5k
Facilitating Awesome Meetings
lara
54
6.5k
Documentation Writing (for coders)
carmenintech
73
5k
Visualization
eitanlees
146
16k
Product Roadmaps are Hard
iamctodd
PRO
54
11k
Reflections from 52 weeks, 52 projects
jeffersonlam
351
21k
Six Lessons from altMBA
skipperchong
28
3.9k
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