Module: Roda::RodaPlugins::NotAllowed::RequestMethods
- Defined in:
- lib/roda/plugins/not_allowed.rb
Instance Method Summary collapse
-
#is(*verbs) ⇒ Object
Keep track of verb calls inside the block.
Instance Method Details
#is(*verbs) ⇒ Object
Keep track of verb calls inside the block. If there are any verb calls inside the block, but the block returned, assume that the verb calls inside the block did not match, and since there was already a successful terminal match, the request method must not be allowed, so return a 405 response in that case.
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/roda/plugins/not_allowed.rb', line 113 def is(*verbs) super(*verbs) do begin @_is_verbs = [] ret = if verbs.empty? yield else yield(*captures) end unless @_is_verbs.empty? response.status = 405 response['Allow'] = @_is_verbs.join(', ') end ret ensure @_is_verbs = nil end end end |