-
-
Notifications
You must be signed in to change notification settings - Fork 120
Description
I'm trying to contribute to the rspec-openapi library and I'm using hanami 2 in production. In rspec-openapi, there is a dummy test application on rails that I am trying to re-implementon hanami.
In particular, the original application in some cases transmits data in the following formats: application/x-www-form-urlencoded and multipart/form-data when upload images.
I'm reading this article https://guides.hanamirb.org/v2.1/actions/formats-and-mime-types/ and I'm following this link over 50 of the most common MIME types and I can't find the MIME-type I need in the list.
By default I'm using form :json, so I'm trying to get around the problem manually:
module HanamiTest
class App < Hanami::App
config.actions.formats.add(:form, "application/x-www-form-urlencoded")
config.actions.formats.add(:multipart, "multipart/form-data")
config.actions.format :json, :form, :multipart
end
endBut I only succeed with form data.
I researched Hanami::Action::Mime.accepted_mime_type?
def accepted_mime_type?(mime_type, config)
accepted_mime_types(config).any? { |accepted_mime_type|
::Rack::Mime.match?(mime_type, accepted_mime_type)
}
endi get
irb(Hanami::Action::Mime):001:0> mime_type
=> "multipart/form-data; boundary=----------XnJLe9ZIbbGUYtzPQJ16u1"
irb(Hanami::Action::Mime):002:0> accepted_mime_types(config)
=> ["multipart/form-data"]I also found this code for FormParser but couldn't find any documentation for it and have no idea how to use it.
Any help would be appreciated.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status