SlideShare a Scribd company logo
SOMETHING SOMETHING RACK
OH, HI!


• Joren

• Openminds

• @joren

• tech.jorendegroof.be
OVERVIEW


• Rack   what?

• Why    Rack?

• How    do you use it?

• Middleware
RACK WHAT?
RACK WHAT?


Rack is a specification (and implementation) of a minimal
           abstract Ruby API that models HTTP
WHY RACK?



• Stop   writing handlers for every webserver

• Keep   the request and response simple
WHY RACK?
Supported web servers
WHY RACK?
Supported web frameworks
HOW DO YOU USE IT?
How to call it?
lambda { |env|
  [
      200,
      {
         ‘Content-Type’ => ‘text/plain’,
         ‘Content-Lenght’ => ‘5’,
      },
      [‘Hello’]
    ]
}
HOW DO YOU USE IT?
HOW DO YOU USE IT?
How to call it?
lambda { |env|
  [
      200,
      {
         ‘Content-Type’ => ‘text/plain’,
         ‘Content-Lenght’ => ‘5’,
      },
      [‘Hello’]
    ]
}
HOW DO YOU USE IT?
How to call it?
lambda { |env|
  [
      200,
      {
         ‘Content-Type’ => ‘text/plain’,
         ‘Content-Lenght’ => ‘5’,
      },
      [‘Hello’]
    ]
}
HOW DO YOU USE IT?
How to call it?
lambda { |env|
  [
     200,
     {
        ‘Content-Type’ => ‘text/plain’,
        ‘Content-Lenght’ => ‘5’,
     },
     [‘Hello’]
   ]
}
HOW DO YOU USE IT?
How to call it?
lambda { |env|
  [
      200,
      {
         ‘Content-Type’ => ‘text/plain’,
         ‘Content-Lenght’ => ‘5’,
      },
      [‘Hello’]
    ]
}
HOW DO YOU USE IT?
How to call it?
lambda { |env|
  [
    200,
        {
            ‘Content-Type’ => ‘text/plain’,
            ‘Content-Lenght’ => ‘5’,
        },
        [‘Hello’]
    ]
}
HOW DO YOU USE IT?
How to call it?
lambda { |env|
  [
      200,
      {
         ‘Content-Type’ => ‘text/plain’,
         ‘Content-Lenght’ => ‘5’,
      },
      [‘Hello’]
    ]
}
HOW DO YOU USE IT?
How to call it?
run lambda { |env|
  [
      200,
      {
         ‘Content-Type’ => ‘text/plain’,
         ‘Content-Lenght’ => ‘5’,
      },
      [‘Hello’]
    ]
}
config.ru
$ rackup config.ru
$ curl http://localhost:9292
Hello
HOW DO YOU USE IT?

class HelloWorld
  def call(env)
   [200, {"Content-Type" => "text/plain"}, ["Hello World!"]]
  end
end
env
REQUEST_METHOD
env[‘REQUEST_METHOD’]
GET
PUT
POST
DELETE
HEAD
OPTIONS
TRACE
PATH_INFO
/items/123
HTTP_*
HTTP_ACCEPT
rack.*
yournamespace.*
request = Rack::Request.new(env)
request.post?
HOW DO YOU USE IT?


       Example
MIDDLEWARE
        Middleware   App



HTTP
use Middleware A
use Middleware B
use Middleware C
run app
class GoSlower
  def initialize(app)
   @app = app
  end

 def call(env)
  sleep(1)
  @app.call(env)
 end
end
class GoSlower
  def initialize(app)
   @app = app
  end

 def call(env)
  sleep(1)
  @app.call(env)
 end
end
class GoSlower
  def initialize(app)
   @app = app
  end

 def call(env)
  sleep(1)
  @app.call(env)
 end
end
class GoSlower
  def initialize(app)
   @app = app
  end

 def call(env)
  sleep(1)
  @app.call(env)
 end
end
IN YOUR RAILS APP

#environment.rb

config.middleware.use “Rack::GoSlower”

config.middleware.use “Rack::Cache”,
    :verbose => true,
    :metastrore => ‘file:/path/to/dir’,
    :entitystore => 'memcached://localhost:11211/body'
EXAMPLES
RACK::HONEYPOT
http://github.com/sunlightlabs/rack-honeypot
RACK::CACHE
http://github.com/rtomayko/rack-cache
WARDEN + DEVISE
  http://github.com/hassox/warden
http://github.com/plataformatec/devise
RACK::DEBUG
http://github.com/ddollar/rack-debug
RACK::GEOIP
http://github.com/b/rack-geoip
RACK::GOOGLE-ANALYTICS
http://github.com/leehambley/rack-google-analytics
RACK::REWRITE
http://github.com/jtrupiano/rack-rewrite
RACK::MOBILE-DETECT
http://github.com/talison/rack-mobile-detect
RACK::CONTRIB
http://github.com/rack/rack-contrib
QUESTIONS?

More Related Content

PPTX
Day of code
PDF
Cucumber: 小黃瓜驗收測試工具
PDF
Zend Framework Components for non-framework Development
PPTX
Custom WordPress theme development
PDF
OpenERP and Perl
PPT
Slim RedBeanPHP and Knockout
PDF
Perl in the Internet of Things
PPTX
WordPress theme development from scratch : ICT MeetUp 2013 Nepal
Day of code
Cucumber: 小黃瓜驗收測試工具
Zend Framework Components for non-framework Development
Custom WordPress theme development
OpenERP and Perl
Slim RedBeanPHP and Knockout
Perl in the Internet of Things
WordPress theme development from scratch : ICT MeetUp 2013 Nepal

Similar to Something something rack (20)

PDF
Rack Middleware
PDF
Rack - O hério oculto de aplicações web Rub.pdf
PPTX
HackU PHP and Node.js
KEY
Using and scaling Rack and Rack-based middleware
KEY
Scalalable Language for a Scalable Web
ODP
Modern Web Development with Perl
PDF
PDF
Ruby MVC from scratch with Rack
PDF
Ruby conf 2011, Create your own rails framework
KEY
Doing Things the WordPress Way
KEY
mod_rewrite bootcamp, Ohio LInux 2011
PPTX
PHP Basics and Demo HackU
PPT
Website designing company_in_delhi_phpwebdevelopment
PDF
Interceptors: Into the Core of Pedestal
PDF
PHP Programming and its Applications workshop
PDF
Supercharging WordPress Development in 2018
PPT
A Brief Introduce to WSGI
PDF
How to build a High Performance PSGI/Plack Server
PDF
Building Web-API without Rails, Registration or SMS
PPTX
Node.js Express
Rack Middleware
Rack - O hério oculto de aplicações web Rub.pdf
HackU PHP and Node.js
Using and scaling Rack and Rack-based middleware
Scalalable Language for a Scalable Web
Modern Web Development with Perl
Ruby MVC from scratch with Rack
Ruby conf 2011, Create your own rails framework
Doing Things the WordPress Way
mod_rewrite bootcamp, Ohio LInux 2011
PHP Basics and Demo HackU
Website designing company_in_delhi_phpwebdevelopment
Interceptors: Into the Core of Pedestal
PHP Programming and its Applications workshop
Supercharging WordPress Development in 2018
A Brief Introduce to WSGI
How to build a High Performance PSGI/Plack Server
Building Web-API without Rails, Registration or SMS
Node.js Express
Ad

More from joren de groof (12)

KEY
Git techtalk
PDF
PDF
Validation
PDF
PDF
Rubyandrails
PDF
Rails Servers
PDF
PDF
PDF
PDF
Mistakes
PDF
Cucumber
Git techtalk
Validation
Rubyandrails
Rails Servers
Mistakes
Cucumber
Ad

Recently uploaded (20)

PDF
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
PDF
August Patch Tuesday
PDF
Mushroom cultivation and it's methods.pdf
PDF
WOOl fibre morphology and structure.pdf for textiles
PPTX
OMC Textile Division Presentation 2021.pptx
PPTX
Tartificialntelligence_presentation.pptx
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Web App vs Mobile App What Should You Build First.pdf
PDF
Enhancing emotion recognition model for a student engagement use case through...
PDF
Encapsulation theory and applications.pdf
PPTX
A Presentation on Touch Screen Technology
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
1. Introduction to Computer Programming.pptx
PDF
Hybrid model detection and classification of lung cancer
PPTX
cloud_computing_Infrastucture_as_cloud_p
PDF
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
A novel scalable deep ensemble learning framework for big data classification...
PDF
Encapsulation_ Review paper, used for researhc scholars
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
August Patch Tuesday
Mushroom cultivation and it's methods.pdf
WOOl fibre morphology and structure.pdf for textiles
OMC Textile Division Presentation 2021.pptx
Tartificialntelligence_presentation.pptx
Digital-Transformation-Roadmap-for-Companies.pptx
MIND Revenue Release Quarter 2 2025 Press Release
Web App vs Mobile App What Should You Build First.pdf
Enhancing emotion recognition model for a student engagement use case through...
Encapsulation theory and applications.pdf
A Presentation on Touch Screen Technology
Agricultural_Statistics_at_a_Glance_2022_0.pdf
1. Introduction to Computer Programming.pptx
Hybrid model detection and classification of lung cancer
cloud_computing_Infrastucture_as_cloud_p
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
A novel scalable deep ensemble learning framework for big data classification...
Encapsulation_ Review paper, used for researhc scholars

Something something rack

Editor's Notes

  • #6: wrapping HTTP requests and responses in the simplest way possible
  • #8: rack includes several handlers for the first web servers, the other distributions have included rack handlers on their own
  • #9: this means, you can run any of these frameworks on any of the previous web servers! without any changes Camping support is included in rack
  • #10: accepts basic ruby object like a lambda
  • #11: accepts basic ruby object like a lambda
  • #12: basic ruby object respond to call like a lambda
  • #13: take 1 argument the environment
  • #14: accepts basic ruby object like a lambda
  • #15: accepts basic ruby object like a lambda
  • #16: hash key value pairs for header
  • #17: body must respond to each now just a string in an Array
  • #23: don’t need to use lambda’s
  • #30: http style header params
  • #31: like http accept
  • #32: rack namespaced protected keys in the environment
  • #33: your own environment namespace
  • #34: wrap it in a request object
  • #36: normal builder toto
  • #37: everytinh in front of our app
  • #42: call down the next thing down stream this is the power of the middleware returning the result