RACK
a framework to t roll your own

Revealing Hour Creations
@nishantmodak
revealinghour.in
Donald Knuth

Email is a wonderful thing
for people whose role in life
is to be on top of things. But
not for me; my role ...
What is Rack?

SERVER
SERVER

APPLICATION /
FRAMEWORK
What is Rack?
1. Web Server Interface
2. Tool for composing web applications
3. Collection of middleware utilities
RACK
config.ru

$ rackup
Middleware
HTTP

INTERMEDIARIES

APP
HTTP
APPLICATION

M
I
D
D
L
E
W
A
R
E
DSL use, run, map
lib/builder.rb
DEMO
1. MyRackApp
2. Middlewares - use / run / map
3. Rack Code
Rack::Builder
> rake middleware
SERVER

MIDDLEWARE

MIDDLEWARE

FRAMEWORK

MIDDLEWARE

ROUTING

MIDDLEWARE

APPLICATION

APPLICATION
Yay! Full Stack Developers!
WHY ANOTHER FRAMEWORK ?
Yes, We CAN !
CRUDingly awful
Maybe
- fearware
- too bloated
- too simple
- over default ing
-
Maybe
- fearware
- too bloated
- too simple
- over default ing
- troll your own framework
justrails.rb
➔ Controllers
➔ Routing
➔ Views
➔ Models
1_application
2_Controllers
- Conventions
- URL Matching
- Autoloading
Conventions
1. <host>/products/index
2. ProductsController#index
3. products_controller
4. <app>/application/controllers
Autoloading
- const_get
-

const_missing

-

$LOAD_PATH
3_View

Interface to several Ruby template engines
3_View

Interface to several Ruby template engines
4_Methods as Rack Applications
5_Routing
Options?
➔ Middlewares
➔ Action* , Active*
➔ Inheritance
References
- edgeguides.rubyonrails.org/rails_on_rack.html
- rebuilding-rails.com
- Sinatra, Rails, Thin
Thank You!
Rack   a framework to roll your own
Rack   a framework to roll your own
Rack   a framework to roll your own
Upcoming SlideShare
Loading in …5
×

Rack a framework to roll your own

480 views

Published on

https://github.com/nishantmodak/chotu

https://github.com/nishantmodak/ruby-talk-au/

( Ruby Conf Australia 2014 )

What is common between Rails, Sinatra and numerous other Ruby frameworks?

They are built on top of Rack or have Rack interfaces for allowing application servers to connect to them.

A deep-dive of sorts on Rack and see what it takes to build a framework, helping us understand these better and ultimately rolling our own.

Almost anyone doing a Ruby app ends up using Rack in one way or the other without ever realising the magic and simplicity that it provides. This session should help decoding that and provide ways on writing your own frameworks.

In involved live coding a framework that is very similar in structure to rails but is bare bones.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
480
On SlideShare
0
From Embeds
0
Number of Embeds
9
Actions
Shares
0
Downloads
5
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Rack a framework to roll your own

  1. 1. RACK a framework to t roll your own Revealing Hour Creations @nishantmodak revealinghour.in
  2. 2. Donald Knuth Email is a wonderful thing for people whose role in life is to be on top of things. But not for me; my role is to be on the bottom of things. http://www-cs-faculty.stanford.edu/~knuth/email.html
  3. 3. What is Rack? SERVER SERVER APPLICATION / FRAMEWORK
  4. 4. What is Rack? 1. Web Server Interface 2. Tool for composing web applications 3. Collection of middleware utilities
  5. 5. RACK
  6. 6. config.ru $ rackup
  7. 7. Middleware HTTP INTERMEDIARIES APP
  8. 8. HTTP APPLICATION M I D D L E W A R E
  9. 9. DSL use, run, map lib/builder.rb
  10. 10. DEMO 1. MyRackApp 2. Middlewares - use / run / map 3. Rack Code
  11. 11. Rack::Builder
  12. 12. > rake middleware
  13. 13. SERVER MIDDLEWARE MIDDLEWARE FRAMEWORK MIDDLEWARE ROUTING MIDDLEWARE APPLICATION APPLICATION
  14. 14. Yay! Full Stack Developers!
  15. 15. WHY ANOTHER FRAMEWORK ?
  16. 16. Yes, We CAN !
  17. 17. CRUDingly awful
  18. 18. Maybe - fearware - too bloated - too simple - over default ing -
  19. 19. Maybe - fearware - too bloated - too simple - over default ing - troll your own framework
  20. 20. justrails.rb ➔ Controllers ➔ Routing ➔ Views ➔ Models
  21. 21. 1_application
  22. 22. 2_Controllers - Conventions - URL Matching - Autoloading
  23. 23. Conventions 1. <host>/products/index 2. ProductsController#index 3. products_controller 4. <app>/application/controllers
  24. 24. Autoloading - const_get - const_missing - $LOAD_PATH
  25. 25. 3_View Interface to several Ruby template engines
  26. 26. 3_View Interface to several Ruby template engines
  27. 27. 4_Methods as Rack Applications
  28. 28. 5_Routing
  29. 29. Options? ➔ Middlewares ➔ Action* , Active* ➔ Inheritance
  30. 30. References - edgeguides.rubyonrails.org/rails_on_rack.html - rebuilding-rails.com - Sinatra, Rails, Thin
  31. 31. Thank You!

×