Sha256: a6586bfd6077f5310213ab844eaa3755069d616218ad8b7d0fcabee30b9c5a53

Contents?: true

Size: 828 Bytes

Versions: 4

Compression:

Stored size: 828 Bytes

Contents

# Versioners set env['api.version'] when a version is defined on an API and
# on the requests. The current methods for determining version are:
#
#   :header - version from HTTP Accept header.
#   :path   - version from uri. e.g. /v1/resource
#   :param  - version from uri query string, e.g. /v1/resource?apiver=v1
#
# See individual classes for details.
module Grape
  module Middleware
    module Versioner
      extend self

      # @param strategy [Symbol] :path, :header or :param
      # @return a middleware class based on strategy
      def using(strategy)
        case strategy
        when :path
          Path
        when :header
          Header
        when :param
          Param
        else
          raise ArgumentError.new("Unknown :using for versioner: #{strategy}")
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
grape-0.2.6 lib/grape/middleware/versioner.rb
grape-0.2.5 lib/grape/middleware/versioner.rb
grape-0.2.4 lib/grape/middleware/versioner.rb
grape-0.2.3 lib/grape/middleware/versioner.rb