File: sendfile_response.rb

package info (click to toggle)
ruby-grape 1.6.2-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 2,156 kB
  • sloc: ruby: 25,265; makefile: 7
file content (21 lines) | stat: -rw-r--r-- 461 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# frozen_string_literal: true

module Grape
  module ServeStream
    # Response should respond to to_path method
    # for using Rack::SendFile middleware
    class SendfileResponse < Rack::Response
      def respond_to?(method_name, include_all = false)
        if method_name == :to_path
          @body.respond_to?(:to_path, include_all)
        else
          super
        end
      end

      def to_path
        @body.to_path
      end
    end
  end
end