~/talk

Miles more maintainable: building APIs with the middleware pattern

Talkat RubyC 2018 · 2018-06-02..06-03· [ruby, api-design]
links:none on file
slides:none on file

Rails controllers with many before_action filters become tangled — a real controller at GoCardless grows to 12 filters with shared instance-variable state and hurting tests. The middleware pattern replaces filters with single‑purpose classes chained as a pipeline (implemented in a toy 25‑line simple middleware), passing an immutable state hash and returning Rack responses or delegating onward, which makes unit tests trivial. A production gem, Coach (github.com/gocardless/coach), adds middleware dependency declaration, config and boot‑time dependency checks so routes declare they require user and middleware reliably provide it.

AI-written summary · about

  1. 0:00Introduction
  2. 2:26The middleware pattern
  3. 8:35Pain and maintainability
  4. 10:00Hard to understand
  5. 15:12Middleware pattern
  6. 19:03Simple middleware
  7. 23:15Refactor
  8. 33:10Recap
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.