module Roda::RodaPlugins::NotAllowed::RequestMethods
def is(*args)
response in that case.
request method must not be allowed, so return a 405
since there was already a successful terminal match, the
that the verb calls inside the block did not match, and
verb calls inside the block, but the block returned, assume
Keep track of verb calls inside the block. If there are any
def is(*args) super(*args) do begin is_verbs = @_is_verbs = [] ret = if args.empty? yield else yield(*captures) end unless is_verbs.empty? method_not_allowed(is_verbs.join(', ')) end ret ensure @_is_verbs = nil end end end
def method_not_allowed(verbs)
to the given string of allowed request methods.
Set the response status to 405 (Method Not Allowed), and set the Allow header
def method_not_allowed(verbs) res = response res.status = 405 res[RodaResponseHeaders::ALLOW] = verbs nil end
def root
response for non-GET requests.
Treat r.root
similar to r.get ''
, using a 405
def root super if @remaining_path == "/" && !is_get? always{method_not_allowed("GET")} end end