Sha256: 1a3f07756b3d40c70ce527e57f7c1f2f4e1eae5d74bbf01a8e9f30f4574a8e23
Contents?: true
Size: 1.13 KB
Versions: 4
Compression:
Stored size: 1.13 KB
Contents
require 'rack/cors' require 'rack-rewrite' require 'rack-server-pages' require 'otr-activerecord' if SlackRubyBotServer::Config.activerecord? && !defined?(::Rails) module SlackRubyBotServer module Api class Middleware def self.logger @logger ||= begin STDOUT.sync = true Logger.new(STDOUT) end end def self.instance @instance ||= Rack::Builder.new do use OTR::ActiveRecord::ConnectionManagement if SlackRubyBotServer::Config.activerecord? && defined?(::OTR) use Rack::Cors do allow do origins '*' resource '*', headers: :any, methods: %i[get post] end end # rewrite HAL links to make them clickable in a browser use Rack::Rewrite do r302 %r{(\/[\w\/]*\/)(%7B|\{)?(.*)(%7D|\})}, '$1' end use Rack::ServerPages do |config| config.view_path = SlackRubyBotServer::Config.view_paths end run Middleware.new end.to_app end def call(env) Endpoints::RootEndpoint.call(env) end end end end
Version data entries
4 entries across 4 versions & 1 rubygems