tag:blogger.com,1999:blog-8477445975588753706.post8081521667958856138..comments2023-10-11T03:45:48.420-07:00Comments on Standards: Accepting Both Get And Post Method in Sinatraujmhttp://www.blogger.com/profile/08682772434896813808noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-8477445975588753706.post-80634214786121910172013-04-24T02:26:06.973-07:002013-04-24T02:26:06.973-07:00Hello,
now there's a better way, Sinatra has...Hello, <br /><br />now there's a better way, Sinatra has an extension API: http://www.sinatrarb.com/extensions.html <br /><br />So, modern rewrite of get_or_post:<br /><br />require 'rubygems'<br />require 'sinatra'<br /><br />module Sinatra<br /> module GetOrPost<br /> def get_or_post(path, options = {}, &block)<br /> get(path, options, &block)<br /> post(path, options, &block)<br /> end<br /> end<br /><br /> register GetOrPost<br />end<br /><br />get_or_post '/' do<br /> 'hi'<br />endlucastejhttps://www.blogger.com/profile/14137091937666387949noreply@blogger.comtag:blogger.com,1999:blog-8477445975588753706.post-17222568574283875352009-11-05T00:05:18.108-08:002009-11-05T00:05:18.108-08:00It's another way of this :)It's another way of this :)ujmhttps://www.blogger.com/profile/08682772434896813808noreply@blogger.comtag:blogger.com,1999:blog-8477445975588753706.post-4997051250637599782009-11-04T06:37:16.893-08:002009-11-04T06:37:16.893-08:00What about :
require 'rubygems'
require &...What about :<br /><br />require 'rubygems'<br />require 'sinatra'<br /><br />code = lambda { 'hi' }<br /><br />get '/', &code<br />post '/', &codeUnknownhttps://www.blogger.com/profile/03555760080029934196noreply@blogger.com