SlideShare uma empresa Scribd logo
1 de 25
Baixar para ler offline
Merb
An Introduction
Who am I?
History
Key Focus
Fast
(No code is faster than no code)
Memory Efficient
Modular
(All you need none you don’t)
As Simple As Possible
Features
Plugins as Gems
Rack Integration
File upload example using rack middleware
uploader = Proc.new do |env|
 request = Merb::Request.new(env)
 if request.path =~ //images/upload/
   params = request.params
   FileUtils.mv params[:file][:tempfile].path,
       Merb.root / 'public' / 'uploads' / params[:file][:filename]

  headers = {quot;Content-Typequot;=>quot;text/htmlquot;,
          quot;Locationquot; => quot;/imagesquot;}
  [302, headers, quot;You are being redirectedquot;]
 else
  [404, {}, quot;No Upload here, move alongquot;]
 end
end

merb = Merb::Rack::Application.new

run Rack::Cascade.new([uploader, merb])
Router
Optional Path Segments
Matching
 match(quot;/articles(/:year(/:month(/:day)))/:titlequot;).
 to(:controller => quot;articlesquot;, :action => quot;showquot;).
 name(:article)

Generating
 /articles/Hello => { :title => “Hello” }
 /articles/2008/07/Hello
   => { :year => “2008”, :month => “07”, :title => “Hello” }
Access to Request &
               Params
     match(quot;/secretquot;).defer_to do |request, params|
      if request.session.authenticated?
        params
      end
     end

http://www.slideshare.net/carllerche/merb-pluming-the-router-presentation
Controllers
class Posts < Application
  provides :xml

 def show
  @post = Post.get(params[:id])
  display @post
 end
end
Background Processing
render_then_call do
  send_notification
end

run_later do
  send_notification
end
Exceptions
class Exceptions < Merb::Controller

 # handle NotFound exceptions (404)
 def not_found
  render :format => :html
 end

 # handle NotAcceptable exceptions (406)
 def not_acceptable
  render :format => :html
 end

end
Merb Slice
Application Server
merb -e produciton -d -c 4
Processes
• master
• spawner
• worker
Hot Deploy
kill HUP ‘master process id’
Questions?

Mais conteúdo relacionado

Mais procurados

Introduction to Fuel
Introduction to FuelIntroduction to Fuel
Introduction to Fuel
Phil Sturgeon
 
Introduction to Web Programming with Perl
Introduction to Web Programming with PerlIntroduction to Web Programming with Perl
Introduction to Web Programming with Perl
Dave Cross
 

Mais procurados (20)

Cucumber: How I Slice It
Cucumber: How I Slice ItCucumber: How I Slice It
Cucumber: How I Slice It
 
[WSO2Con EU 2017] An Overview of Ballerina Composer
[WSO2Con EU 2017] An Overview of Ballerina Composer[WSO2Con EU 2017] An Overview of Ballerina Composer
[WSO2Con EU 2017] An Overview of Ballerina Composer
 
BioMake PAG 2017
BioMake PAG 2017 BioMake PAG 2017
BioMake PAG 2017
 
using Mithril.js + postgREST to build and consume API's
using Mithril.js + postgREST to build and consume API'susing Mithril.js + postgREST to build and consume API's
using Mithril.js + postgREST to build and consume API's
 
Tutorial on joomla transfer moffatmn
Tutorial on joomla transfer moffatmnTutorial on joomla transfer moffatmn
Tutorial on joomla transfer moffatmn
 
Rack Middleware
Rack MiddlewareRack Middleware
Rack Middleware
 
jQuery Intro
jQuery IntrojQuery Intro
jQuery Intro
 
OpenERP and Perl
OpenERP and PerlOpenERP and Perl
OpenERP and Perl
 
Rails Engines as a way to Micro services
Rails Engines as a way to Micro servicesRails Engines as a way to Micro services
Rails Engines as a way to Micro services
 
RoR 101: Session 1
RoR 101: Session 1RoR 101: Session 1
RoR 101: Session 1
 
Task Scheduling and Asynchronous Processing Evolved. Zend Server Job Queue
Task Scheduling and Asynchronous Processing Evolved. Zend Server Job QueueTask Scheduling and Asynchronous Processing Evolved. Zend Server Job Queue
Task Scheduling and Asynchronous Processing Evolved. Zend Server Job Queue
 
Rack is Spectacular
Rack is SpectacularRack is Spectacular
Rack is Spectacular
 
Introduction to asp
Introduction to aspIntroduction to asp
Introduction to asp
 
Introduction to Fuel
Introduction to FuelIntroduction to Fuel
Introduction to Fuel
 
Introduction to Web Programming with Perl
Introduction to Web Programming with PerlIntroduction to Web Programming with Perl
Introduction to Web Programming with Perl
 
wp-n00b.php
wp-n00b.phpwp-n00b.php
wp-n00b.php
 
Module design pattern i.e. express js
Module design pattern i.e. express jsModule design pattern i.e. express js
Module design pattern i.e. express js
 
Understanding JSP -Servlets
Understanding JSP -ServletsUnderstanding JSP -Servlets
Understanding JSP -Servlets
 
Rack
RackRack
Rack
 
Ruby on Rails Meets Enterprise Applications
Ruby on Rails Meets Enterprise ApplicationsRuby on Rails Meets Enterprise Applications
Ruby on Rails Meets Enterprise Applications
 

Destaque

Destaque (17)

Action And Linking Verbs
Action And Linking VerbsAction And Linking Verbs
Action And Linking Verbs
 
191319
191319191319
191319
 
Nouns
NounsNouns
Nouns
 
Learning and Research - Junior Camp Internship Programme
Learning and Research - Junior Camp Internship ProgrammeLearning and Research - Junior Camp Internship Programme
Learning and Research - Junior Camp Internship Programme
 
Adjectives Vs
Adjectives VsAdjectives Vs
Adjectives Vs
 
Abortion
AbortionAbortion
Abortion
 
Homonyms
HomonymsHomonyms
Homonyms
 
Adjectives Vs Adverbs
Adjectives Vs AdverbsAdjectives Vs Adverbs
Adjectives Vs Adverbs
 
Linking Verbs
Linking VerbsLinking Verbs
Linking Verbs
 
Internet and Social Media: making the most of the global platform
Internet and Social Media: making the most of the global platformInternet and Social Media: making the most of the global platform
Internet and Social Media: making the most of the global platform
 
Dm Intro
Dm IntroDm Intro
Dm Intro
 
Prepositional Phrases
Prepositional PhrasesPrepositional Phrases
Prepositional Phrases
 
Overview of Woekpor Digital Literacy Initiative
Overview of Woekpor Digital Literacy InitiativeOverview of Woekpor Digital Literacy Initiative
Overview of Woekpor Digital Literacy Initiative
 
Job Applications
Job ApplicationsJob Applications
Job Applications
 
Introduction to Junior Camp Internship Programme
Introduction to Junior Camp Internship ProgrammeIntroduction to Junior Camp Internship Programme
Introduction to Junior Camp Internship Programme
 
Visual Rhetoric
Visual RhetoricVisual Rhetoric
Visual Rhetoric
 
Nouns
NounsNouns
Nouns
 

Semelhante a Merb

Intro To Mvc Development In Php
Intro To Mvc Development In PhpIntro To Mvc Development In Php
Intro To Mvc Development In Php
funkatron
 
Integrating Flex And Rails With Ruby Amf
Integrating Flex And Rails With Ruby AmfIntegrating Flex And Rails With Ruby Amf
Integrating Flex And Rails With Ruby Amf
railsconf
 
En story of cakephp2.0
En story of cakephp2.0En story of cakephp2.0
En story of cakephp2.0
Hiroki Shimizu
 
symfony on action - WebTech 207
symfony on action - WebTech 207symfony on action - WebTech 207
symfony on action - WebTech 207
patter
 

Semelhante a Merb (20)

And the Greatest of These Is ... Rack Support
And the Greatest of These Is ... Rack SupportAnd the Greatest of These Is ... Rack Support
And the Greatest of These Is ... Rack Support
 
Rugalytics | Ruby Manor Nov 2008
Rugalytics | Ruby Manor Nov 2008Rugalytics | Ruby Manor Nov 2008
Rugalytics | Ruby Manor Nov 2008
 
All I Need to Know I Learned by Writing My Own Web Framework
All I Need to Know I Learned by Writing My Own Web FrameworkAll I Need to Know I Learned by Writing My Own Web Framework
All I Need to Know I Learned by Writing My Own Web Framework
 
Service Oriented Integration With ServiceMix
Service Oriented Integration With ServiceMixService Oriented Integration With ServiceMix
Service Oriented Integration With ServiceMix
 
SproutCore and the Future of Web Apps
SproutCore and the Future of Web AppsSproutCore and the Future of Web Apps
SproutCore and the Future of Web Apps
 
Damage Control
Damage ControlDamage Control
Damage Control
 
More Secrets of JavaScript Libraries
More Secrets of JavaScript LibrariesMore Secrets of JavaScript Libraries
More Secrets of JavaScript Libraries
 
Rapid Prototyping FTW!!!
Rapid Prototyping FTW!!!Rapid Prototyping FTW!!!
Rapid Prototyping FTW!!!
 
Intro To Mvc Development In Php
Intro To Mvc Development In PhpIntro To Mvc Development In Php
Intro To Mvc Development In Php
 
Integrating Flex And Rails With Ruby Amf
Integrating Flex And Rails With Ruby AmfIntegrating Flex And Rails With Ruby Amf
Integrating Flex And Rails With Ruby Amf
 
Flex With Rubyamf
Flex With RubyamfFlex With Rubyamf
Flex With Rubyamf
 
Sinatra
SinatraSinatra
Sinatra
 
En story of cakephp2.0
En story of cakephp2.0En story of cakephp2.0
En story of cakephp2.0
 
Ruby Isn't Just About Rails
Ruby Isn't Just About RailsRuby Isn't Just About Rails
Ruby Isn't Just About Rails
 
Apache and PHP: Why httpd.conf is your new BFF!
Apache and PHP: Why httpd.conf is your new BFF!Apache and PHP: Why httpd.conf is your new BFF!
Apache and PHP: Why httpd.conf is your new BFF!
 
Curso Symfony - Clase 4
Curso Symfony - Clase 4Curso Symfony - Clase 4
Curso Symfony - Clase 4
 
Jsf Ajax
Jsf AjaxJsf Ajax
Jsf Ajax
 
symfony on action - WebTech 207
symfony on action - WebTech 207symfony on action - WebTech 207
symfony on action - WebTech 207
 
Zend Con 2008 Slides
Zend Con 2008 SlidesZend Con 2008 Slides
Zend Con 2008 Slides
 
Express Presentation
Express PresentationExpress Presentation
Express Presentation
 

Último

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Último (20)

FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

Merb