joshsusser / refraction Goto Github PK
View Code? Open in Web Editor NEWRack middleware replacement for mod_rewrite
Rack middleware replacement for mod_rewrite
Is there any way to access the application routes in the rewrite rules, or do I need to directly specify the URL/path? I tried calling a route method and it failed, saying undefined variable or method.
http://github.com/ghandal/refraction/commit/d2bafbff80a8e5a76017a246ef3c5488ddd35333
This should be included in your gem since whole application can silently fail outputing only nginx error which can't be seen in hoptoad - then for instance some clients may get angry and won't use your app anymore. Or smth like that.
Fork author provides more details on this issue.
I don't know if it's a Bundler issue or a Refraction issue, but when I attempt to use the Gem via Bundler, I receive an error on boot while things work fine if I include Refraction as a plugin. I'd much prefer to use the Gem.
`load_missing_constant':NameError: uninitialized constant Refraction
My environment files includes:
config.middleware.insert_before(::Rack::Lock, ::Refraction, {})
NoMethodError: undefined method `empty?' for nil:NilClass
/Library/Ruby/Gems/1.8/gems/rack-1.0.1/lib/rack/commonlogger.rb:53:in each' /Library/Ruby/Gems/1.8/gems/rack-1.0.1/lib/rack/lint.rb:499:in
each'
/Library/Ruby/Gems/1.8/gems/rack-1.0.1/lib/rack/commonlogger.rb:36:in each' /Library/Ruby/Gems/1.8/gems/shotgun-0.4/lib/shotgun.rb:96:in
slurp'
/Library/Ruby/Gems/1.8/gems/shotgun-0.4/lib/shotgun.rb:62:in proceed_as_child' /Library/Ruby/Gems/1.8/gems/shotgun-0.4/lib/shotgun.rb:29:in
call!'
/Library/Ruby/Gems/1.8/gems/shotgun-0.4/lib/shotgun.rb:15:in call' /Library/Ruby/Gems/1.8/gems/rack-1.0.1/lib/rack/content_length.rb:13:in
call'
/Library/Ruby/Gems/1.8/gems/rack-1.0.1/lib/rack/chunked.rb:15:in call' /Library/Ruby/Gems/1.8/gems/rack-1.0.1/lib/rack/handler/mongrel.rb:64:in
process'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:159:in process_client' /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in
each'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in process_client' /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in
run'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in initialize' /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in
new'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in run' /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in
initialize'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in new' /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in
run'
/Library/Ruby/Gems/1.8/gems/rack-1.0.1/lib/rack/handler/mongrel.rb:34:in run' /Library/Ruby/Gems/1.8/gems/shotgun-0.4/bin/shotgun:129 /usr/bin/shotgun:19:in
load'
/usr/bin/shotgun:19
req.scheme
seems to always be http on Heroku. I tried logging the scheme in the Refraction config and it would say http even if the completed in Rails log said https.
The release history for refraction looks a little bit strange http://rubygems.org/gems/refraction
0.1.4 was released after 0.2.0, when installing via bundler, it always installs 0.2.0. I'm not sure if I should be using 0.1.4 or 0.2.0. Can anyone provide any insight?
Refraction rocks. I just had one small problem setting it up. Using
config.middleware.insert_before(::Rack::Lock, ::Refraction, {})
in production.rb
gives me the error
gems/refraction-0.2.0/lib/refraction.rb:98:in `initialize':
wrong number of arguments (2 for 1) (ArgumentError)
(I'm running Rails 3.0.0.beta4.)
I removed the third argument and it worked:
config.middleware.insert_before(::Rack::Lock, ::Refraction)
Hi,
I recently tried to use refraction as a plugin with my rails 2.3.2 app.
My effort went like this:
$ script/plugin install git://github.com/pivotal/refraction.git
(plugin installed, initializer added)
Add this line to my environment.rb (to try it on development):
Rails::Initializer.run do |config| config.middleware.insert_before(::Rack::Lock, ::Refraction, {}) end
$ rake middleware
rake aborted!
uninitialized constant Refraction
$ script/console
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:443:in load_missing_constant':NameError: uninitialized constant Refraction /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:443:in
load_missing_constant':NameError: uninitialized constant ApplicationController
Any help, here?
Thanks!
Running the following (in refraction_rules.rb lines 1-3):
Refraction.configure do |req|
req.found! '/asdf_test' if req.path == "/asdf"
end
puts this error in my apache's error_log:
*** Exception NoMethodError in application (super: no superclass method `path') (process 833):
from /Users/.../vendor/plugins/refraction/lib/refraction.rb:66:in `path'
from /Users/.../config/initializers/refraction_rules.rb:2
This is running with apache + Passenger on OSX. Running with webrick gives no error. Any idea why this might be?
This works:
req.permanent! :host => 'fb.local'
But this does not:
req.rewrite! 'fb.local'
Am I missing something? The syntax is identical to the example. If something is not working, I'm not quite sure how to debug the issue, so let me know what you need and I'll provide it.
When I try:
req.params = [updated params]
I get an error because the request object doesn't have that method (writer).
Anyone know how I can update the parameters? It's Ruby, so I know it's possible.
I use refraction with rails 4:
No such middleware to insert before: Rack::Lock
to fix this error change
config.middleware.insert_before(::Rack::Lock, ::Refraction)
to
config.middleware.insert_before(::Rack::Runtime, ::Refraction)
Explanation here: http://stackoverflow.com/questions/17131366/no-such-middleware-to-insert-before-racklock-runtimeerror-after-upgrading
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.