Sha256: 41ed732bfa980a57f4df91d0d197e80c2740561052845e3c5b1d343ee74e1481
Contents?: true
Size: 1.27 KB
Versions: 1
Compression:
Stored size: 1.27 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? use Rack::Cors do allow do origins '*' resource '*', headers: :any, methods: [: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 = [ 'views', # relative to Dir.pwd 'public', # relative to Dir.pwd File.expand_path(File.join(__dir__, '../../../public')) # built-in fallback ] end run Middleware.new end.to_app end def call(env) Endpoints::RootEndpoint.call(env) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
slack-ruby-bot-server-0.6.1 | lib/slack-ruby-bot-server/api/middleware.rb |