Sha256: 1191bda11b7e77676a4575bb10bda065a528d535b22b7c29a44e745a95efb36a

Contents?: true

Size: 1.08 KB

Versions: 4

Compression:

Stored size: 1.08 KB

Contents

require "alf-core"
require "alf-rack"
require "alf/rack/query"
require "rack"
require "rack/robustness"
require "sprockets"

require_relative 'nocache'
require_relative 'webapp'

module Alf
  module Repl
    Service = ::Rack::Builder.new do

      # Log everything on STDOUT
      use ::Rack::CommonLogger

      # Serve the assets through Sprockets
      map '/assets' do
        environment = Sprockets::Environment.new
        environment.append_path Path.backfind('assets/css')
        environment.append_path Path.backfind('assets/js')
        run environment
      end

      # Deploy the query ability under /query
      map '/query' do
        use ::Rack::Robustness do |g|
          g.status 400
          g.content_type "text/plain"
          g.body{|ex| ex.message }
        end
        use ::Rack::Nocache
        use ::Alf::Rack::Connect do |cfg|
          cfg.database = Repl.database
        end
        run ::Alf::Rack::Query.new{|q|
          q.type_check = false
          q.catch_all  = false
        }
      end

      run WebApp
    end # Service
  end # module Repl
end # module Alf

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
alf-repl-0.16.3 lib/alf/repl/service.rb
alf-repl-0.16.2 lib/alf/repl/service.rb
alf-repl-0.16.1 lib/alf/repl/service.rb
alf-repl-0.16.0 lib/alf/repl/service.rb