lib/roda/plugins/halt.rb
# Expand default halt method to handle status codes, headers, and bodies.  See Halt.
Expand default halt method to handle status codes, headers, and bodies.  See Halt.
Expand default halt method to handle status codes headers and bodies . See Halt .
def halt(*res)
          case res.length
          when 0 
          when 1
            case v = res[0]
            when Integer
              response.status = v
            when Array
              throw :halt, v
            else
              if result = block_result_body(v)
                response.write(result)
              else
                raise Roda::RodaError, "singular argument given to #halt not handled: #{v.inspect}"
              end
            end
          when 2
            resp = response
            resp.status = res[0]
            resp.write(block_result_body(res[1]))
          when 3
            resp = response
            resp.status = res[0]
            resp.headers.merge!(res[1])
            resp.write(block_result_body(res[2]))
          else
            raise Roda::RodaError, "too many arguments given to #halt (accepts 0-3, received #{res.length})"
          end
          super()
        end
def halt ( * res ) case res . length when 0 when 1 case v = res [ 0 ] when Integer response . status = v when Array throw :halt , v else if result = block_result_body ( v ) response . write ( result ) else raise Roda :: RodaError , "singular argument given to #halt not handled: #{v.inspect}" end end when 2 resp = response resp . status = res [ 0 ] resp . write ( block_result_body ( res [ 1 ] ) ) when 3 resp = response resp . status = res [ 0 ] resp . headers . merge! ( res [ 1 ] ) resp . write ( block_result_body ( res [ 2 ] ) ) else raise Roda :: RodaError , "too many arguments given to #halt (accepts 0-3, received #{res.length})" end super ( ) end
Expand default halt method to handle status codes, headers, and bodies.
Expand default halt method to handle status codes headers and bodies .
# do nothing
res