Sha256: 26883ce0f8adcc5ed4cd4aed3feb6de7b8013d05be38d5a77ecea9599bf7c07b

Contents?: true

Size: 802 Bytes

Versions: 1

Compression:

Stored size: 802 Bytes

Contents

module Lookout::Rack::Utils
  module Subroute
    def subroute!(relative_path, options={})
      http_verb = request.request_method
      # modify rack environment using Rack::Request- store passed in key/value
      # pairs into hash associated with the parameters of the current http verb
      options.each { |k,v| request.send(http_verb)[k] = v }
      subcode, subheaders, body = call(env.merge('PATH_INFO' => relative_path))
      return [subcode, body.first]
    end

    # Returns true if the status given is 20x
    #
    # @param [Integer] status
    def succeeded?(status)
      status.is_a?(Fixnum) && (200..299).include?(status)
    end

    # Returns false if the status given is 20x
    #
    # @param [Integer] status
    def failed?(status)
      !succeeded?(status)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lookout-rack-utils-1.5.0 lib/lookout/rack/utils/subroute.rb