Class: Rubytus::Middlewares::StorageBarrier
- Inherits:
-
Object
- Object
- Rubytus::Middlewares::StorageBarrier
- Includes:
- Goliath::Rack::AsyncMiddleware, Constants
- Defined in:
- lib/rubytus/middlewares/storage_barrier.rb
Constant Summary
Constants included from Constants
Constants::BASE_PATH_REGEX, Constants::COMMON_HEADERS, Constants::DEFAULT_BASE_PATH, Constants::DEFAULT_DATA_DIR, Constants::DEFAULT_MAX_SIZE, Constants::DEFAULT_STORAGE, Constants::ENV_BASE_PATH, Constants::ENV_DATA_DIR, Constants::ENV_MAX_SIZE, Constants::ENV_STORAGE, Constants::RESOURCE_UID_REGEX, Constants::RESUMABLE_CONTENT_TYPE, Constants::STATUS_BAD_REQUEST, Constants::STATUS_CREATED, Constants::STATUS_FORBIDDEN, Constants::STATUS_INTERNAL_ERROR, Constants::STATUS_NOT_ALLOWED, Constants::STATUS_NOT_FOUND, Constants::STATUS_OK
Instance Method Summary collapse
Instance Method Details
#post_process(env, status, headers, body) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/rubytus/middlewares/storage_barrier.rb', line 9 def post_process(env, status, headers, body) status = STATUS_OK action = env['api.action'] storage = env['api.options'][:storage] begin case action when :create status = STATUS_CREATED headers['Location'] = env['api.resource_url'] storage.create_file(env['api.uid'], env['api.final_length']) when :head info = storage.read_info(env['api.uid']) headers['Offset'] = info.offset.to_s when :get body = storage.read_file(env['api.uid']) end rescue PermissionError => e raise Goliath::Validation::Error.new(500, e.) end [status, headers, body] end |