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
900
Clojureという言語が私逹にもたらしたもの
ayato0211
6
3.1k
3年間考え続けてきたWebアプリケーションにおけるテストの話
ayato0211
3
270
Re:REPL-Driven Development
ayato0211
3
1.3k
Meta Template Engine
ayato0211
2
1.1k
超変換! Hiccup data structure!!
ayato0211
2
610
About Integrant
ayato0211
0
560
Muscle Assert
ayato0211
0
270
Clojureを用いたWebアプリケーション開発
ayato0211
2
3.1k
Other Decks in Programming
See All in Programming
Go言語の特性を活かした公式MCP SDKの設計
hond0413
1
200
なぜGoのジェネリクスはこの形なのか? Featherweight Goが明かす設計の核心
ryotaros
7
1k
CSC509 Lecture 02
javiergs
PRO
0
410
私はどうやって技術力を上げたのか
yusukebe
43
17k
私達はmodernize packageに夢を見るか feat. go/analysis, go/ast / Go Conference 2025
kaorumuta
2
500
AI Coding Meetup #3 - 導入セッション / ai-coding-meetup-3
izumin5210
0
610
階層構造を表現するデータ構造とリファクタリング 〜1年で10倍成長したプロダクトの変化と課題〜
yuhisatoxxx
3
920
overlayPreferenceValue で実現する ピュア SwiftUI な AdMob ネイティブ広告
uhucream
0
110
GitHub Actions × AWS OIDC連携の仕組みと経緯を理解する
ota1022
0
240
Railsだからできる 例外業務に禍根を残さない 設定設計パターン
ei_ei_eiichi
0
350
「ちょっと古いから」って避けてた技術書、今だからこそ読もう
mottyzzz
1
270
Le côté obscur des IA génératives
pascallemerrer
0
130
Featured
See All Featured
GitHub's CSS Performance
jonrohan
1032
460k
Scaling GitHub
holman
463
140k
Writing Fast Ruby
sferik
629
62k
GraphQLの誤解/rethinking-graphql
sonatard
73
11k
Learning to Love Humans: Emotional Interface Design
aarron
274
40k
Become a Pro
speakerdeck
PRO
29
5.5k
Keith and Marios Guide to Fast Websites
keithpitt
411
22k
Rebuilding a faster, lazier Slack
samanthasiow
84
9.2k
The Cult of Friendly URLs
andyhume
79
6.6k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
46
7.6k
Raft: Consensus for Rubyists
vanstee
139
7.1k
Principles of Awesome APIs and How to Build Them.
keavy
127
17k
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