rack

Simple and Ideal Logging in Sinatra

删除回忆录丶 提交于 2019-12-05 01:51:29
问题 I went through few blogs and sites which gave me some information about how to log in sinatra but didnt work for my app and also i went through a gem called sinatra-logger didnt tried it, wanted to know ideal and simple way to "log" in sinatra. Like we do logger.info for rails. The code which i tried and didnt work is from the following site link and also some of SO links were too pointing to the same approach used in the link above. configure do LOGGER = Logger.new("sinatra.log") end helpers

Unicorn vs Passenger Standalone behind nginx [closed]

拟墨画扇 提交于 2019-12-05 01:35:16
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . I'm trying to decide between Unicorn and Phusion Passenger Standalone (formerly Phusion Passenger Lite). I want to host multiple apps on my server. I have nginx running and listening to port 80. I need a webapp server that I can proxy

Adding a custom middleware to Rails 4

余生颓废 提交于 2019-12-05 00:58:05
I have a Rails 4 sample project (Blog) and I have created a simple middleware called 'request_timer' in config/initializers/request_timer.rb #config/initializers/request_timer.rb class RequestTimer def initialize(app) @app = app end def call(env) start_time = Time.now status, headers, response = @app.call(env) stop_time = Time.now [status, headers, response.body] end end and I have added my middleware in config/application.rb in two ways 1 ) Adding as a constant #config/application.rb module Blog class Application < Rails::Application config.middleware.use RequestTimer end end this way when I

Very slow: ActiveRecord::QueryCache#call

二次信任 提交于 2019-12-05 00:28:18
I have an app on heroku, running on Puma: workers 2 threads_count 3 pool 5 It looks like some requests get stuck in the middleware, and it makes the app very slow (VERY!). I have seen other people threads about this problem but no solution so far. Please let me know if you have any hint. ! ! I work for Heroku support and Middleware/Rack/ActiveRecord::QueryCache#call is a commonly reported as a problem by New Relic. Unfortunately, it's usually a red herring as each time the source of the problem lies elsewhere. QueryCache is where Rails first tries to check out a connection for use, so any

Hello World rack middleware with rails 3: how to process body of all requests

孤者浪人 提交于 2019-12-04 23:52:44
问题 i want to try out a simple rack middleware "hello world", but i seem to get stuck. it looks like the main sytax changed, since some examples use this code: require 'rack/utils' class FooBar def initialize(app) @app = app end def call(env) status, headers, body = @app.call(env) body.body << "\nHi from #{self.class}" [status, headers, body] end end produces an error: undefined method `<<' for #<ActionDispatch::Response:0x103f07c48> even when i look at other codes out there, i cannot seem to get

Rails 3 middleware modify request headers

。_饼干妹妹 提交于 2019-12-04 23:22:48
My setup: Rails 3.0.9, Ruby 1.9.2 I am working on my first middleware app and it seems like all of the examples deal with modify the response. I need to examine and modify the request headers in particular, delete some offending headers that cause a bug in Rack 1.2.3 to choke. Here's the typical hello world Rack app. my_middleware.rb class MyMiddleware def initialize(app) @app = app end def call(env) @status, @headers, @response = @app.call(env) [@status, @headers, @response] end end Does anyone have an example that deals with the request headrers and intercepting them before Rack gets hold of

Sinatra rack middleware hijacks '/' root url

天涯浪子 提交于 2019-12-04 22:23:36
I'm trying to use a Sinatra app as middleware in my Rails app. I've tested a basic Sinatra app in the /lib folder of the Rails app, use d the middleware and set a route. That worked fine. What I want to be able to do is extract the Sinatra app and include it as a gem. That way I can run the Sinatra app independently, or use it in multiple Rails apps. Sinatra App # myrackapp/lib/myrackapp.rb module Myrackapp class Application < Sinatra::Base set :root, File.dirname(__FILE__) get "/" do "Rack Home" end get '/rackroute' do "Hello, Rack Page" end end end Myrackapp also has a gemspec – nothing

How to deploy a threadsafe asynchronous Rails app?

a 夏天 提交于 2019-12-04 21:57:27
问题 I've read tons of material around the web about thread safety and performance in different versions of ruby and rails and I think I understand those things quite well at this point. What seems to be oddly missing from the discussions is how to actually deploy an asynchronous Rails app. When talking about threads and synchronicity in an app, there are two things people want to optimize: utilizing all CPU cores with minimal RAM usage being able to serve new requests while previous requests are

Rails 3, HTTP extensions (WebDAV) and Rack App mounting

若如初见. 提交于 2019-12-04 21:15:40
问题 1 The following is more to point out to the code devs an issue of rails that can be percieved as a flaw. 2 And also me asking some oppinions from people who know better. I want to add WebDAV to my Rails 3 App with Warden authentication. My warden middleware is injected via Devise. http://github.com/chrisroberts/dav4rack http://github.com/hassox/warden http://github.com/plataformatec/devise I cannot mount DAV4Rack handlers from inside rails app (routes), like this: # in config/routes.rb mount

How can I test helpers blocks in Sinatra, using Rspec?

孤街醉人 提交于 2019-12-04 17:54:09
问题 I'm writing a sinatra app and testing it with rspec and rack/test (as described on sinatrarb.com). It's been great so far, until I moved some rather procedural code from my domain objects to sinatra helpers. Since then, I've been trying to figure out how to test these in isolation ? 回答1: maybe this can help you some way http://japhr.blogspot.com/2009/03/sinatra-innards-deletgator.html 回答2: I test my sinatra helpers in isolation by putting the helper methods within its own module. Since my