Sha256: 8b2ce75fda7d86fc048876a629ea32accb77940aa1c4ffe353fd74dd7629b616

Contents?: true

Size: 396 Bytes

Versions: 8

Compression:

Stored size: 396 Bytes

Contents

module Routemaster
  module Middleware
    # Rejects all requests but POST to the root path
    class RootPostOnly
      def initialize(app, _options = {})
        @app  = app
      end

      def call(env)
        return [404, {}, []] unless ['', '/'].include? env['PATH_INFO']
        return [405, {}, []] if env['REQUEST_METHOD'] != 'POST'
        @app.call(env)
      end
    end
  end
end


Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
routemaster-drain-3.7.1 lib/routemaster/middleware/root_post_only.rb
routemaster-drain-3.7.0 lib/routemaster/middleware/root_post_only.rb
routemaster-drain-3.6.8 lib/routemaster/middleware/root_post_only.rb
routemaster-drain-3.6.7 lib/routemaster/middleware/root_post_only.rb
routemaster-drain-3.6.6 lib/routemaster/middleware/root_post_only.rb
routemaster-drain-3.6.5 lib/routemaster/middleware/root_post_only.rb
routemaster-drain-3.6.4 lib/routemaster/middleware/root_post_only.rb
routemaster-drain-3.6.3 lib/routemaster/middleware/root_post_only.rb