rack

How to access SSL client certificate from rack app

帅比萌擦擦* 提交于 2020-01-05 18:48:38
问题 Actually -- question title tells almost everything. In earlier Rails (2.x) I've seen code that was accessing client certificate details via request.env hash. My rack app is receiving call with env argument, but this data is not there. How can I access it? 回答1: You should enable this on web server e.g. in Apache do SSLOptions +ExportCertData and/or +StdEnvVars. So you will get SSL_* vars in env. 来源: https://stackoverflow.com/questions/7726182/how-to-access-ssl-client-certificate-from-rack-app

Serving Compressed Assets in Heroku with Rack-Zippy

时光怂恿深爱的人放手 提交于 2020-01-05 10:25:52
问题 I followed this tutorial on how to compress assets in Heroku. http://www.cheynewallace.com/serving-compressed-assets-with-heroku-rack-zippy/ Here is my Application.rb file require File.expand_path('../boot', __FILE__) require 'rails/all' Bundler.require(*Rails.groups) module Blog class Application < Rails::Application config.assets.precompile += %w(*.png *.jpg *.jpeg *.gif) config.exceptions_app = self.routes config.cache_store = :memory_store Rails.application.config.middleware.swap

How to remove the “Server” HTTP response header from my Rack app

只愿长相守 提交于 2020-01-04 07:09:07
问题 I am trying to remove the server information from the http response header in my ruby on rails application running on Heroku but I am stuck. Inspecting the response headers gives me: Server:thin 1.5.0 codename Knife Can anyone point me in the right direction? 回答1: This Server header is set by the Thin server when assembling the response. A recent commit adds the ability to set the Server to something else, but it doesn’t look like you can totally remove it. One thing you can do is to set the

Sinatra tests always 404'ing

不想你离开。 提交于 2020-01-04 02:54:34
问题 I have a very simple Sinatra app which I'm having trouble testing. Basically, every single request test returns a 404 when I know from testing in the browser that the request works fine. Any ideas as to what the problem might be? test_helper.rb: ENV["RACK_ENV"] = 'test' $: << File.expand_path(File.dirname(__FILE__) + '/../lib') require 'app' Sinatra::Synchrony.patch_tests! class Test::Unit::TestCase include Rack::Test::Methods end app_test.rb require 'test_helper' class AppTest < Test::Unit:

Heroku + Rack-Rewrite

一笑奈何 提交于 2020-01-02 08:44:11
问题 Still can't get this working...Rails 3.1.3, Ruby 1.9.2 on Heroku's Cedar Stack. Trying to use https://github.com/jtrupiano/rack-rewrite to make http://domain 301 redirect to http://www.domain to no luck (app works, but no redirects happen at all). /config/initializers/rack_rewrite.rb (MyAppName is actually the correct name, domain.com is actual domain): MyAppName::Application.config.middleware.insert_before(Rack::Lock, Rack::Rewrite) do r301 %r{.*}, 'http://www.domain.com$&', :if => Proc.new

Rails 3: How to declare Rack middleware in application.rb

只愿长相守 提交于 2020-01-02 07:11:32
问题 Many examples such as these two: How to use rack middleware with Rails3? http://asciicasts.com/episodes/151-rack-middleware define middleware in a class and then add config.middleware.use "ClassNameHere" to config/application.rb but I can't figure where in application.rb to add this. I have put it inside of class Application < Rails::Application . I am also not sure if there is a specific location where I put my middleware class. I have mine in /lib. Say my middleware class is called

Can I have Sinatra / Rack not read the entire request body into memory?

五迷三道 提交于 2020-01-01 06:52:33
问题 Say I have a Sinatra route ala: put '/data' do request.body.read # ... end It appears that the entire request.body is read into memory. Is there a way to consume the body as it comes into the system, rather than having it all buffered in Rack/Sinatra beforehand? I see I can do this to read the body in parts, but the entire body still seems to be read into memory beforehand. put '/data' do while request.body.read(1024) != nil # ... end # ... end 回答1: You cannot avoid this in general without

Can I have Sinatra / Rack not read the entire request body into memory?

独自空忆成欢 提交于 2020-01-01 06:52:17
问题 Say I have a Sinatra route ala: put '/data' do request.body.read # ... end It appears that the entire request.body is read into memory. Is there a way to consume the body as it comes into the system, rather than having it all buffered in Rack/Sinatra beforehand? I see I can do this to read the body in parts, but the entire body still seems to be read into memory beforehand. put '/data' do while request.body.read(1024) != nil # ... end # ... end 回答1: You cannot avoid this in general without

best/most elegant way to share objects between a stack of rack mounted apps/middlewares?

Deadly 提交于 2020-01-01 05:23:06
问题 What is the best idiom to share an object between rack mounted applications/middlewares? For example, this config.ru has two Sinatra apps mapped to differents endpoints: class App1 < Sinatra::Base # ... end class App2 < Sinatra::Base # ... end map '/app1' do run App1 end map '/app2' do run App2 end Now if these two applications need to share an object, be it a database connector or any other object, what would be the best idiom for this? I see basically two options: 1- Create a constant at

Where does RACK log to?

落花浮王杯 提交于 2020-01-01 01:58:08
问题 I am running a sinatra app through RACK. To which file does the activity get logged ? Also how can I set the log file path ? 回答1: It depends. Many developers define their app log file to app/servername.log or just to the current path where the Rack app is loaded. Yes you can change it's path. Usually you get a config.ru file with something like: log = File.new("sinatra.log", "a+") $stdout.reopen(log) $stderr.reopen(log) # optionally to sync logs while the server is running $stderr.sync = true