Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Building with Rack
Search
Alexander Clark
February 23, 2016
Programming
410
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Building with Rack
Let's build a Rack app!
Alexander Clark
February 23, 2016
Transcript
27 slides
Building with Rack Alexander Clark
What is Rack?
?
None
?
None
?
?
What does a Rack app look like? ?
What does a Rack app look like? GET /foo HTTP/1.1
Host: localhost:9292 Accept: text/html … ?
What does a Rack app look like? GET /foo HTTP/1.1
Host: localhost:9292 Accept: text/html … ? <!DOCTYPE html> <html> <head> …
run Proc.new { |env| ['200', {'Content-Type' => 'text/html'}, ['get rack\'d']]
}
run Proc.new { |env| ['200', {'Content-Type' => 'text/html'}, ['get rack\'d']]
} Responds to #call HTTP Status code Headers Response body Run
run Proc.new { |env| ['200', {'Content-Type' => 'text/html'}, ['get rack\'d']]
} Responds to #call Much HTTP Status code Such Headers Response body Wow Run
Let’s build something!
None
<!DOCTYPE html> <html> <head> <title>Is it April Fools?</title> </head> <body>
<h1><%= @april_fools ? 'YES' : 'NO' %></h1> </body> </html>
require 'erb' class MyRackApp def initialize @april_fools = Time.now.strftime('%m%d') ==
'0401' end def call(_env) ['200', {'Content-Type' => 'text/html'}, view] end def view [ERB.new(template).result(binding)] end def template File.open('index.html.erb', 'r').read end end
require './my_rack_app' run MyRackApp.new
None
?
run Proc.new { |env| ['200', {'Content-Type' => 'text/html'}, ['get rack\'d']]
} run MyRackApp.new ... def call(_env) ['200', {'Content-Type' => 'text/html'}, view] end
run MyRackApp.new run Rails.application
Middleware
TL;DL
Further Reading • https://rack.github.io/ • http://alexander-clark.com/blog/building-a-rack-app/ • http://www.justinweiss.com/articles/a-web-server-vs- an-app-server/ •
https://www.amberbit.com/blog/2011/07/13/ introduction-to-rack-middleware/
Thanks for Listening Alexander Clark atheclark alexander-clark.com alexander-clark
More Decks by Alexander Clark
See All by Alexander Clark
Off the Rails: Patterns for fixing fat models, out-of-controllers, and other Rails problems
alexanderclark
0
390
Docker: What It Is and Why You Should Care
alexanderclark
0
420
Other Decks in Programming
See All in Programming
FactoryBotをやめればRSpecは速くなるのか?
yuta_onishi_97
0
1.7k
小さなアプリを作って公開するまで
onozaty
0
180
止まらない比較を止める — 余帰納法で無限ストリームを比べる
tarao
0
170
graphql-ruby を Spinel で速くしようとした話
mtsmfm
0
150
AIが実装を担う時代の「技術設計」と「チームマネジメント」
kamina_zzz
2
270
Materialが消えた日 〜真っ白なFlutterキャンバスにRenderObjectで絵を描く〜
umigishiaoi
0
160
Kawaiicon: Kubernetes, it's no longer cool, but let's secure it anyway!
barnbarn
0
130
선언형 햅틱 라이브러리 진동을 소개합니다
l2hyunwoo
1
320
Web3Dライブラリを作ってVue Custom Rendererの仕組みを理解しよう / lets learn vue custom renderer by making 3d library
drumath2237
1
140
Goコンパイラを作ってGoをもっと理解する / Build a Go compiler to better understand Go
ikura_hamu
0
130
Enforcing Your Architecture with Unit Tests in the AI Era (Swift Connection X)
steliosf
PRO
1
180
flutter_test のその先へ — Flutter アプリの LLM 機能に「評価」という品質保証を
kosukesaigusa
0
200
Featured
See All Featured
The Language of Interfaces
destraynor
162
27k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
2
350
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
2
400
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
590
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
121
130k
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
300
The Pragmatic Product Professional
lauravandoore
37
7.5k
Side Projects
sachag
456
43k
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
1
300
How Software Deployment tools have changed in the past 20 years
geshan
3
35k
The agentic SEO stack - context over prompts
schlessera
0
1k
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
350