Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Sinatra::Ftw
Search
Luciano Sousa
September 18, 2010
Programming
0
86
Sinatra::Ftw
An introduction about Sinatra Framework
Luciano Sousa
September 18, 2010
Tweet
Share
More Decks by Luciano Sousa
See All by Luciano Sousa
Playing with Sorbet
lucianosousa
0
46
Knowing mina deploy
lucianosousa
1
67
Creating your startup without Developer
lucianosousa
0
160
Patterns Falacy v2
lucianosousa
0
120
Project Management like Software Developer
lucianosousa
1
110
The Patterns Falacy - Rails Version
lucianosousa
1
100
Other Decks in Programming
See All in Programming
deno-redisの紹介とJSRパッケージの運用について (toranoana.deno #21)
uki00a
0
140
明示と暗黙 ー PHPとGoの インターフェイスの違いを知る
shimabox
2
270
PHPで始める振る舞い駆動開発(Behaviour-Driven Development)
ohmori_yusuke
2
170
エラーって何種類あるの?
kajitack
5
290
Java on Azure で LangGraph!
kohei3110
0
170
XP, Testing and ninja testing
m_seki
3
170
What Spring Developers Should Know About Jakarta EE
ivargrimstad
0
190
20250628_非エンジニアがバイブコーディングしてみた
ponponmikankan
0
320
イベントストーミング図からコードへの変換手順 / Procedure for Converting Event Storming Diagrams to Code
nrslib
1
280
第9回 情シス転職ミートアップ 株式会社IVRy(アイブリー)の紹介
ivry_presentationmaterials
1
230
すべてのコンテキストを、 ユーザー価値に変える
applism118
2
580
型付きアクターモデルがもたらす分散シミュレーションの未来
piyo7
0
800
Featured
See All Featured
Fashionably flexible responsive web design (full day workshop)
malarkey
407
66k
Typedesign – Prime Four
hannesfritz
42
2.7k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
26
2.8k
How to Think Like a Performance Engineer
csswizardry
24
1.7k
Bootstrapping a Software Product
garrettdimon
PRO
307
110k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
10
930
Adopting Sorbet at Scale
ufuk
77
9.4k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
31
1.2k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
44
2.4k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
33
5.9k
GraphQLとの向き合い方2022年版
quramy
47
14k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
53
2.8k
Transcript
http://twitter.com/lucianosousa 1 Sinatra::Ftw Luciano Sousa
[email protected]
http://lucianosousa.net http://twitter.com/lucianosousa http://github.com/lucianosousa
http://twitter.com/lucianosousa 2 Sinatra::WTF? ✔ Micro Framework web ✔ DSL ✔
Rotas ✔ Múltiplos Templates ✔ Filtros ✔ Exemplos
http://twitter.com/lucianosousa 3 Sinatra::Description Micro Framework para desenvolvimento de aplicações web
com o mínimo de esforço.
http://twitter.com/lucianosousa 4 Sinatra::DSL get '/hi' do “hello world!” end Domain
Specific Language
http://twitter.com/lucianosousa 5 Sinatra::Routes get '/' do “get in index” end
post '/' do “post in index” end put '/' do “put in index” end delete '/' do “delete in index” end get '/:name' do “Hello #{params[:name]}!” end
http://twitter.com/lucianosousa 6 Sinatra::Templates get '/' do “hello world!” end get
'/' do erb :index end get '/' do haml :index end get '/' do erubis :index end
http://twitter.com/lucianosousa 7 Sinatra::Layout get '/' do erb :index end Carrega
arquivo arquivo layout.template dentro da pasta views automagicamente
http://twitter.com/lucianosousa 8
http://twitter.com/lucianosousa 9
http://twitter.com/lucianosousa 10
http://twitter.com/lucianosousa 11
http://twitter.com/lucianosousa 12 Sinatra::Helpers helpers do def sum(value) "Result: #{value.to_i+100}" end
end get '/:value' do sum(params[:value]) end Obs: O parâmetro :value é passado como string para o helper.
http://twitter.com/lucianosousa 13
http://twitter.com/lucianosousa 14 Sinatra::Filters after do puts "Response status is: #{response.status}"
end
http://twitter.com/lucianosousa 15
http://twitter.com/lucianosousa 16 Sinatra::Example