require 'crepe/versioning/request'

module Crepe
  module Versioning
    module Endpoint
      # The most acceptable format requested, e.g. +:json+.
      #
      # @return [Symbol]
      def format
        return @format if defined? @format
        formats = Util.media_types config[:formats]
        media_type = request.accepts.best_of formats
        @format = config[:formats].find { |f| Util.media_type(f) == media_type }
      end
    end
  end
end

Crepe::Endpoint.send(:prepend, Crepe::Versioning::Endpoint)

require 'crepe/versioning/request'

module Crepe
  module Versioning
    # Crepe::Endpoint needs a format override.
    module Endpoint
      # The most acceptable format requested, e.g. +:json+.
      #
      # @return [Symbol]
      def format
        return @format if defined? @format
        formats = Util.media_types config[:formats]
        media_type = request.accepts.best_of formats
        @format = config[:formats].find { |f| Util.media_type(f) == media_type }
      end
    end
  end
end

Crepe::Endpoint.send(:prepend, Crepe::Versioning::Endpoint)

Add explanatory comment to Crepe::Versioning::Endpoint
Add explanatory comment to Crepe::Versioning::Endpoint

Signed-off-by: David Celis <b1c1d8736f20db3fb6c1c66bb1455ed43909f0d8@davidcel.is>
