mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-26 01:35:34 +08:00
Add special middleware for handling of Rails 5.1 WOPI errors
Closes SCI-2266.
This commit is contained in:
parent
159078170a
commit
386ede0400
2 changed files with 23 additions and 0 deletions
19
app/middlewares/wopi_method_override.rb
Normal file
19
app/middlewares/wopi_method_override.rb
Normal file
|
@ -0,0 +1,19 @@
|
|||
# When WOPI performs calls onto sciNote WOPI subdomain REST endpoints
|
||||
# Rack::MethodOverride MUST be omitted because it crashes the requests
|
||||
# due to trying to parse body of the requests
|
||||
class WopiMethodOverride
|
||||
def initialize(app)
|
||||
@app = app
|
||||
end
|
||||
|
||||
def call(env)
|
||||
app = @app
|
||||
|
||||
unless WopiSubdomain.matches?(ActionDispatch::Request.new(env))
|
||||
# Use the wrapped Rack::MethodOverride middleware
|
||||
app = Rack::MethodOverride.new(@app)
|
||||
end
|
||||
|
||||
app.call(env)
|
||||
end
|
||||
end
|
|
@ -15,6 +15,10 @@ module Scinote
|
|||
# Application configuration should go into files in config/initializers
|
||||
# -- all .rb files in that directory are automatically loaded.
|
||||
|
||||
# Swap the Rack::MethodOverride with a wrapped middleware for WOPI handling
|
||||
require_relative '../app/middlewares/wopi_method_override'
|
||||
config.middleware.swap Rack::MethodOverride, WopiMethodOverride
|
||||
|
||||
# Load all model concerns, including subfolders
|
||||
config.autoload_paths += Dir["#{Rails.root}/app/models/concerns/**/*.rb"]
|
||||
|
||||
|
|
Loading…
Reference in a new issue