34
RACK a framework to roll your own @nishantmodak Revealing Hour Creations t revealinghour.in

Rack a framework to roll your own

Embed Size (px)

Citation preview

Page 1: Rack   a framework to roll your own

RACKa framework to roll your own

@nishantmodak

Revealing Hour Creations

t

revealinghour.in

Page 2: Rack   a framework to roll your own
Page 3: Rack   a framework to roll your own

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

Page 4: Rack   a framework to roll your own

SERVER

What is Rack?

APPLICATION / FRAMEWORK

SERVER

Page 5: Rack   a framework to roll your own

1. Web Server Interface 2. Tool for composing web applications 3. Collection of middleware utilities

What is Rack?

Page 6: Rack   a framework to roll your own

RACK

Page 7: Rack   a framework to roll your own

config.ru

$ rackup

Page 8: Rack   a framework to roll your own

APP

HTTP

INTERMEDIARIES

Middleware

Page 9: Rack   a framework to roll your own

HTTP

APPLICATION

M I D D L E W A R E

Page 10: Rack   a framework to roll your own

DSL use, run, map

lib/builder.rb

Page 11: Rack   a framework to roll your own

DEMO

1. MyRackApp

2. Middlewares - use / run / map

3. Rack Code

Page 12: Rack   a framework to roll your own

Rack::Builder

Page 13: Rack   a framework to roll your own
Page 14: Rack   a framework to roll your own

> rake middleware

Page 15: Rack   a framework to roll your own

MIDDLEWARE

MIDDLEWARE

MIDDLEWARE

ROUTING

MIDDLEWARE APPLICATION

APPLICATION

SERVER

FRAMEWORK

Page 16: Rack   a framework to roll your own

Yay! Full Stack Developers!

Page 17: Rack   a framework to roll your own

WHY ANOTHER FRAMEWORK ?

Page 18: Rack   a framework to roll your own

Yes, We CAN !

Page 19: Rack   a framework to roll your own

CRUDingly awful

Page 20: Rack   a framework to roll your own

Maybe

- fearware

- too bloated

- too simple

- over default ing

-

Page 21: Rack   a framework to roll your own

Maybe

- fearware

- too bloated

- too simple

- over default ing

- troll your own framework

Page 22: Rack   a framework to roll your own

justrails.rb

➔ Controllers ➔ Routing

➔ Views

➔ Models

Page 23: Rack   a framework to roll your own

1_application

Page 24: Rack   a framework to roll your own

2_Controllers

- Conventions

- URL Matching

- Autoloading

Page 25: Rack   a framework to roll your own

Conventions

1. <host>/products/index

2. ProductsController#index

3. products_controller

4. <app>/application/controllers

Page 26: Rack   a framework to roll your own

Autoloading

- const_get

- const_missing

- $LOAD_PATH

Page 27: Rack   a framework to roll your own

3_View

Interface to several Ruby template engines

Page 28: Rack   a framework to roll your own

3_View

Interface to several Ruby template engines

Page 29: Rack   a framework to roll your own

4_Methods as Rack Applications

Page 30: Rack   a framework to roll your own

5_Routing

Page 31: Rack   a framework to roll your own

Options?

➔ Middlewares ➔ Action* , Active*

➔ Inheritance

Page 32: Rack   a framework to roll your own

References

- edgeguides.rubyonrails.org/rails_on_rack.html

- rebuilding-rails.com

- Sinatra, Rails, Thin

Page 33: Rack   a framework to roll your own

Thank You!

Page 34: Rack   a framework to roll your own