Class: Bucketrb::App
- Inherits:
-
Object
- Object
- Bucketrb::App
- Defined in:
- lib/bucketrb/app.rb
Constant Summary collapse
- XML_CONTENT_TYPE =
"application/xml"- DEFAULT_CONTENT_TYPE =
"application/octet-stream"
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(store:) ⇒ App
constructor
A new instance of App.
Constructor Details
#initialize(store:) ⇒ App
Returns a new instance of App.
16 17 18 |
# File 'lib/bucketrb/app.rb', line 16 def initialize(store:) @store = store end |
Instance Method Details
#call(env) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/bucketrb/app.rb', line 20 def call(env) request = Rack::Request.new(env) return if request. bucket, key = path_parts(request.path_info) if bucket.nil? return root_request(request) end dispatch(request, bucket, key) rescue Bucketrb::BucketNotFoundError => error error_response("NoSuchBucket", error., 404, head: env["REQUEST_METHOD"] == "HEAD") rescue Bucketrb::ObjectNotFoundError => error error_response("NoSuchKey", error., 404, head: env["REQUEST_METHOD"] == "HEAD") rescue Bucketrb::InvalidBucketNameError, Bucketrb::InvalidObjectKeyError, ArgumentError => error error_response("InvalidArgument", error., 400, head: env["REQUEST_METHOD"] == "HEAD") rescue StandardError => error warn "#{error.class}: #{error.}" warn error.backtrace.join("\n") if ENV["BUCKETRB_DEBUG"] error_response("InternalError", error., 500, head: env["REQUEST_METHOD"] == "HEAD") end |