Rails 3, Http Extensions (Webdav) and Rack App Mounting

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

And we have a winner.
https://rails.lighthouseapp.com/projects/8994/tickets/5895-allow-mounting-of-rack-apps-that-deal-with-http-extensions

Rails 5: Rack app mounted in routes.rb bypasses Rails middleware?

Found it. Turns out I was mounting one of these apps in config.ru as well, under the same URL - and then of course the entire Rails stack gets bypassed, as it should be. Lesson learned.

How to create rack application to be used by Rails?

I got my question answered in another question:

How to read POST data in rack request

require 'json'

class Greeter
def call(env)
req = Rack::Request.new(env)
if req.post?
puts req.POST()
end
[200, {"Content-Type" => "application/json"}, [{x:"Hello World!"}.to_json]]
end
end

run Greeter.new

and use JSON.parse( req.body.read ) to parse POST data.

reload rails.root/app/resources/* per request

I am currently using the following hack, if anyone has a better solution please do share!

# config/environments/development.rb
root = config.root
config.to_prepare do
load "#{root}/app/resources/file_resource.rb"
end


Related Topics



Leave a reply



Submit