Rack application that accepts GET request to the root URL, calls #presign
on the specified storage, and returns that information in JSON format.
Constants
CONTENT_TYPE_JSON | = | "application/json; charset=utf-8" | ||
CONTENT_TYPE_TEXT | = | "text/plain" |
Public Instance Aliases
to_s | -> | inspect |
Public Class methods
new(options)
Writes given options to instance variables.
[show source]
# File lib/shrine/plugins/presign_endpoint.rb 67 def initialize(options) 68 options.each do |name, value| 69 instance_variable_set("@#{name}", value) 70 end 71 end
Public Instance methods
call(env)
Accepts a Rack env hash, routes GET requests to the root URL, and returns a Rack response triple.
If request isn’t to the root URL, a 404 Not Found
response is returned. If request verb isn’t GET, a 405 Method Not Allowed
response is returned.
[show source]
# File lib/shrine/plugins/presign_endpoint.rb 79 def call(env) 80 request = Rack::Request.new(env) 81 82 status, headers, body = catch(:halt) do 83 error!(404, "Not Found") unless ["", "/"].include?(request.path_info) 84 85 if request.get? 86 handle_request(request) 87 elsif request.options? 88 handle_options_request(request) 89 else 90 error!(405, "Method Not Allowed") 91 end 92 end 93 94 headers["Content-Length"] ||= body.map(&:bytesize).inject(0, :+).to_s 95 96 [status, headers, body] 97 end
inspect()
[show source]
# File lib/shrine/plugins/presign_endpoint.rb 99 def inspect 100 "#<#{@shrine_class}::PresignEndpoint(:#{@storage_key})>" 101 end