Remove need for monads

This commit is contained in:
2023-01-31 19:43:12 +11:00
parent 8a54a584f2
commit ccd778ecbb

View File

@@ -10,18 +10,16 @@ module Adamantium
halt 401 unless verify_scope(req: req, scope: :media)
upload.call(file: data) do |m|
m.failure do |v|
res.status = 422
end
upload_result = upload.call(file: data)
m.success do |v|
res.status = 201
res.headers["Location"] = v
res.body = {
url: v
}.to_json
end
res.status = 422 if upload_result.failure?
if upload_result.success?
res.status = 201
res.headers["Location"] = upload_result.value!
res.body = {
url: upload_result.value!
}.to_json
end
end
end