Class: Weary::Middleware::ContentType
- Inherits:
-
Object
- Object
- Weary::Middleware::ContentType
- Defined in:
- lib/weary/middleware/content_type.rb
Constant Summary collapse
- CONTENT_TYPE =
'CONTENT_TYPE'- CONTENT_LENGTH =
'CONTENT_LENGTH'- FORM_URL_ENCODED =
'application/x-www-form-urlencoded'- MULTIPART_FORM =
'multipart/form-data'
Instance Attribute Summary collapse
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, type = FORM_URL_ENCODED) ⇒ ContentType
constructor
A new instance of ContentType.
- #length(input) ⇒ Object
Constructor Details
#initialize(app, type = FORM_URL_ENCODED) ⇒ ContentType
Returns a new instance of ContentType.
12 13 14 15 |
# File 'lib/weary/middleware/content_type.rb', line 12 def initialize(app, type = FORM_URL_ENCODED) @app = app @type = type end |
Instance Attribute Details
#type ⇒ Object (readonly)
Returns the value of attribute type.
10 11 12 |
# File 'lib/weary/middleware/content_type.rb', line 10 def type @type end |
Instance Method Details
#call(env) ⇒ Object
17 18 19 20 21 |
# File 'lib/weary/middleware/content_type.rb', line 17 def call(env) env.update CONTENT_TYPE => @type env.update CONTENT_LENGTH => length(env['rack.input']) @app.call(env) end |
#length(input) ⇒ Object
23 24 25 |
# File 'lib/weary/middleware/content_type.rb', line 23 def length(input) input.size.to_s end |