Stupid Middleware Tricks
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

Stupid Middleware Tricks

on

  • 3,827 views

My challenge, new middleware everyday. Here is my lightning talk about writing weird Rack Middlewares

My challenge, new middleware everyday. Here is my lightning talk about writing weird Rack Middlewares

Statistics

Views

Total Views
3,827
Views on SlideShare
3,784
Embed Views
43

Actions

Likes
5
Downloads
34
Comments
0

3 Embeds 43

http://www.joshbuddy.com 35
http://www.slideshare.net 7
http://209.85.129.132 1

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />

Stupid Middleware Tricks Presentation Transcript

  • 1. Stupid Rack Middleware Tricks josh@aiderss.com @joshbuddy http://github.com/joshbuddy
  • 2. What is Rack?
  • 3. What is Rack? Standard interface for HTTP servers and application.
  • 4. What is Rack? Standard interface for HTTP servers and application. CGI, FastCGI, Mongrel, Thin, WEBrick and many more!
  • 5. What is Rack? Standard interface for HTTP servers and application. CGI, FastCGI, Rails, Merb, Mongrel, Thin, Sinatra, Ramaze, WEBrick a proc and many more! your next great framework
  • 6. What is Rack Middleware?
  • 7. What is Rack Middleware? HTTP Server
  • 8. What is Rack Middleware? HTTP Server Application
  • 9. What is Rack Middleware? HTTP Server Application
  • 10. What is Rack Middleware? Transparent Intercepting Caching Content filtering
  • 11. What is Rack Middleware? Transparent Intercepting Caching Content filtering (insert your thingy here)
  • 12. My Challenge
  • 13. My Challenge I'm going to write a new Rack Middleware everyday of RailsConf.
  • 14. My Challenge I'm going to write a new Rack Middleware everyday of RailsConf. (with tests)
  • 15. #1 Rack::Rewrite http://github.com/joshbuddy/rack-rewrite
  • 16. #1 Rack::Rewrite http://github.com/joshbuddy/rack-rewrite Get a request, rewrite it!
  • 17. #1 Rack::Rewrite http://github.com/joshbuddy/rack-rewrite Get a request, rewrite it! I hates this
  • 18. #1 Rack::Rewrite http://github.com/joshbuddy/rack-rewrite use Rack::Rewrite do on :method => 'get' do # If the request has a has a param of kitten=cute or # kitten=happy, lets log it and pass it on! # on :params => {:kitten => /cute|happy/} do act { log('what a nice cat') } pass end fail end end
  • 19. #2 Rack::Regenerate http://github.com/joshbuddy/rack-regenerate
  • 20. #2 Rack::Regenerate http://github.com/joshbuddy/rack-regenerate No idea. But say you had a request. And it was something you wanted to get hit every five minutes.
  • 21. #2 Rack::Regenerate http://github.com/joshbuddy/rack-regenerate X-Cache-Regenerate: [interval in seconds] [number of times to call]
  • 22. #2 Rack::Regenerate http://github.com/joshbuddy/rack-regenerate X-Cache-Regenerate: [interval in seconds] [number of times to call] X-Cache-Regenerate: 2 5 Request
  • 23. #2 Rack::Regenerate http://github.com/joshbuddy/rack-regenerate X-Cache-Regenerate: [interval in seconds] [number of times to call] X-Cache-Regenerate: 2 5 Request Response
  • 24. #2 Rack::Regenerate http://github.com/joshbuddy/rack-regenerate X-Cache-Regenerate: [interval in seconds] [number of times to call] X-Cache-Regenerate: 2 5 Request Response Intercept
  • 25. #2 Rack::Regenerate http://github.com/joshbuddy/rack-regenerate X-Cache-Regenerate: [interval in seconds] [number of times to call] X-Cache-Regenerate: 2 5 Request Response Intercept 2 seconds
  • 26. #2 Rack::Regenerate http://github.com/joshbuddy/rack-regenerate X-Cache-Regenerate: [interval in seconds] [number of times to call] X-Cache-Regenerate: 2 5 Request Response Intercept 2 seconds 2 seconds
  • 27. #2 Rack::Regenerate http://github.com/joshbuddy/rack-regenerate X-Cache-Regenerate: [interval in seconds] [number of times to call] X-Cache-Regenerate: 2 5 Request Response Intercept 2 seconds 2 seconds 5.times!
  • 28. #3 Rack::Capabilities http://github.com/joshbuddy/rack-capabilities
  • 29. #3 Rack::Capabilities http://github.com/joshbuddy/rack-capabilities Middleware
  • 30. #3 Rack::Capabilities http://github.com/joshbuddy/rack-capabilities Middleware Middleware
  • 31. #3 Rack::Capabilities http://github.com/joshbuddy/rack-capabilities Middleware Middleware Middleware
  • 32. #3 Rack::Capabilities http://github.com/joshbuddy/rack-capabilities Middleware Middleware Middleware Middleware
  • 33. #3 Rack::Capabilities http://github.com/joshbuddy/rack-capabilities Middleware Who’s that Middleware middleware Middleware ? Middleware
  • 34. #3 Rack::Capabilities http://github.com/joshbuddy/rack-capabilities # who is before me? Rack::Capabilities.before(self) # who is after me? Rack::Capabilities.after(self) # where can I go find AGoodTime? Rack::Capabilities.find(AGoodTime) # ==> nil
  • 35. #4 Rack::CacheWhileRevalidate http://github.com/joshbuddy/rack-cache-while-revalidate
  • 36. #4 Rack::CacheWhileRevalidate http://github.com/joshbuddy/rack-cache-while-revalidate Request
  • 37. #4 Rack::CacheWhileRevalidate http://github.com/joshbuddy/rack-cache-while-revalidate Request Cache
  • 38. #4 Rack::CacheWhileRevalidate http://github.com/joshbuddy/rack-cache-while-revalidate STALE! Request Cache
  • 39. #4 Rack::CacheWhileRevalidate http://github.com/joshbuddy/rack-cache-while-revalidate Request Cache Application Revalidate Serve stale data
  • 40. The End?