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
85
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
43
Knowing mina deploy
lucianosousa
1
58
Creating your startup without Developer
lucianosousa
0
160
Patterns Falacy v2
lucianosousa
0
110
Project Management like Software Developer
lucianosousa
1
100
The Patterns Falacy - Rails Version
lucianosousa
1
97
Other Decks in Programming
See All in Programming
DROBEの生成AI活用事例 with AWS
ippey
0
130
コミュニティ駆動 AWS CDK ライブラリ「Open Constructs Library」 / community-cdk-library
gotok365
2
140
データの整合性を保つ非同期処理アーキテクチャパターン / Async Architecture Patterns
mokuo
48
17k
Amazon Bedrock Multi Agentsを試してきた
tm2
1
290
なぜイベント駆動が必要なのか - CQRS/ESで解く複雑系システムの課題 -
j5ik2o
12
4.1k
Rails アプリ地図考 Flush Cut
makicamel
1
120
社内フレームワークとその依存性解決 / in-house framework and its dependency management
vvakame
1
560
2024年のWebフロントエンドのふりかえりと2025年
sakito
3
250
pylint custom ruleで始めるレビュー自動化
shogoujiie
0
120
Grafana Cloudとソラカメ
devoc
0
170
Honoのおもしろいミドルウェアをみてみよう
yusukebe
1
210
楽しく向き合う例外対応
okutsu
0
150
Featured
See All Featured
Reflections from 52 weeks, 52 projects
jeffersonlam
348
20k
The Art of Programming - Codeland 2020
erikaheidi
53
13k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.3k
Docker and Python
trallard
44
3.3k
Keith and Marios Guide to Fast Websites
keithpitt
411
22k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
27
1.6k
Designing for Performance
lara
604
68k
Large-scale JavaScript Application Architecture
addyosmani
511
110k
We Have a Design System, Now What?
morganepeng
51
7.4k
Code Review Best Practice
trishagee
67
18k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
Faster Mobile Websites
deanohume
306
31k
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