rack

How to use Rack map to run two Thin (or other) servers on different ports?

拟墨画扇 提交于 2019-12-22 08:35:35
问题 My aim is to do some automated testing over HTTP and HTTPS/SSL, via Rack, without recourse to a proxy server setup or anything like that. I have a gem that I want to test and I'd like for others to be able to run tests on too, so I'd like it to be as self contained as possible. The code for App runs fine when run on it's own, so it's not included here, the problem is with the Rack part. I'd like to do something like this: app = Rack::Builder.app do map "/" do Rack::Handler::WEBrick.run App,

Alter response.body in Rack Middleware

心已入冬 提交于 2019-12-22 08:16:02
问题 I'm trying to write some Rack Middleware for a Rails 4.2 app that alters the response body using the gsub method. I found older examples that use a pattern like this: class MyMiddleware def initialize(app) @app = app end def call(env) status, headers, response = @app.call(env) # do some stuff [status, headers, response] end end What I'm finding is that there is no setter method for response.body . Is there another pattern I can start with to go about modifying the body? 回答1: The problem was

How do I create a resque worker automatically at bootup?

谁说我不能喝 提交于 2019-12-22 08:09:00
问题 Ok, I'm making my first ruby app. Who know moving everything over to 'production' is so fugging complicated. So far I've struggled my way through configuring passenger, getting it to run on startup, then getting redis to run on startup. My last task is on startup to add 1 worker. Right now, I have to ssh in and run my rake command rake workers:start . Obviously this is no good when I want to close ssh.. so I just dont really know how or what the next step is. I tried copying resque default

Unicorn vs Passenger Standalone behind nginx [closed]

蓝咒 提交于 2019-12-22 03:52:14
问题 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

problem with rack 1.3.2. You have already activated rack 1.3.2, but your Gemfile requires rack 1.2.3

北城以北 提交于 2019-12-21 19:40:13
问题 i have passenger 3.0.9 on debian with gem rack 1.3.2 and 1.2.1. With a rails 3.0 application with passenger e bundler i have this error: You have already activated rack 1.3.2, but your Gemfile requires rack 1.2.3. Consider using bundle exec. With rails 3.1 is all ok. I can't make start application with rails 3.0 but only with 3.1. Passnnger load first rack 1.3.2 and don't load rack 1.2.3 on gems of bundler 回答1: Short answer: you need to run bundle update rack This will update your rack

Rack Sessions getting lost in Chrome

会有一股神秘感。 提交于 2019-12-21 17:34:37
问题 I have an pretty simple app hosted on EC2 built with Sinatra, served with thin behind nginx. The problem is that with Chrome, the session variables get 'lost' in Sinatra. It does not happen in Firefox. This is using Rack::Session::Cookie. This is similar to this issue: Sinatra not persisting session with redirect on Chrome Any insights in how to solve this issues in Chrome would be appreciated. 回答1: Make sure you are setting the following: configure :development do set(:session_secret, 'a

Why is rack response body an array not a string?

浪子不回头ぞ 提交于 2019-12-21 06:57:45
问题 a classic hello world example from their doc, class HelloWorld def call(env) return [200, {}, ["Hello world!"]] end end my question is why the third value is [Hello world!"], not "Hello world"? From their doc, The Body must respond to each and must only yield String values. The Body itself should not be an instance of String, as this will break in Ruby 1.9. Why body needs to respond to each? and in what case does it matter? 回答1: I think rack originated on python's wsgi. Here is the

Why are there frozen constants everywhere?

血红的双手。 提交于 2019-12-21 06:53:49
问题 We can easily find such style from lots of famous repositories, like rack, rails, etc. For example in rack: PATH_INFO = 'PATH_INFO'.freeze REQUEST_METHOD = 'REQUEST_METHOD'.freeze SCRIPT_NAME = 'SCRIPT_NAME'.freeze QUERY_STRING = 'QUERY_STRING'.freeze CACHE_CONTROL = 'Cache-Control'.freeze CONTENT_LENGTH = 'Content-Length'.freeze CONTENT_TYPE = 'Content-Type'.freeze Another examle in rails: HTTP_IF_MODIFIED_SINCE = 'HTTP_IF_MODIFIED_SINCE'.freeze HTTP_IF_NONE_MATCH = 'HTTP_IF_NONE_MATCH'

Rack: How do you store the URL as a variable?

假装没事ソ 提交于 2019-12-21 05:01:01
问题 I am writing a simple static Rack app. Check out the config.ru code below: use Rack::Static, :urls => ["/elements", "/img", "/pages", "/users", "/css", "/js"], :root => "archive" map '/' do run Proc.new { |env| [ 200, { 'Content-Type' => 'text/html', 'Cache-Control' => 'public, max-age=6400' }, File.open('archive/splash.html', File::RDONLY) ] } end map '/pages/search.html' do run Proc.new { |env| [ 200, { 'Content-Type' => 'text/html', 'Cache-Control' => 'public, max-age=6400' }, File.open(

Problem with require rack/openid in Rails 3 [native require work properly]

一曲冷凌霜 提交于 2019-12-21 04:27:40
问题 I install plugin open_id_authentication and have this error: /usr/lib/ruby/gems/1.9.1/gems/activesupport-3.0.0.beta/lib/active_support/dependencies.rb:167:in `require': no such file to load -- rack/openid (LoadError) when I try to start rails server Actually, rack-openid installed in my system and i can load it from irb: irb(main):001:0> require 'rack/openid' => true I tried to add hack to Gemfile as I did with ruby-openid, but it did't help: gem "ruby-openid", :require => "openid" gem "rack