Sha256: 53421aa5e7cc5bcbdedfac275dbaedc9ed15b712f2f3ccb664a03a8833421445
Contents?: true
Size: 1.16 KB
Versions: 18
Compression:
Stored size: 1.16 KB
Contents
module JSONAPIonify::Api module Base::AppBuilder def self.extended(klass) klass.class_eval do extend JSONAPIonify::InheritedAttributes inherited_array_attribute :middleware end end def use(*args, &block) middleware << [args, block] end def call(env) app.call(env) end private def app api = self Rack::Builder.new do use Rack::ShowExceptions use Rack::CommonLogger use Base::Reloader unless ENV['RACK_ENV'] == 'production' map "/docs" do run ->(env) { request = JSONAPIonify::Api::Server::Request.new env if request.path_info.present? return [301, { 'location' => request.path.chomp(request.path_info) }, []] end response = Rack::Response.new response.write api.documentation_output(request) response.finish } end map "/" do use Rack::MethodOverride api.middleware.each do |args, block| use *args, &block end run JSONAPIonify::Api::Server.new(api) end end end end end
Version data entries
18 entries across 18 versions & 1 rubygems