Module: Roy::Halt

Defined in:
lib/roy/halt.rb

Overview

This module adds a halt method to the application context that allows you to break during a handler and immediately return a status code and a body.

Included by default.

Examples:

A Not Found application


class NotFoundApp
  include Roy

  def get(_)
    halt 404
  end
end

Test


$ curl -i localhost:9292
HTTP/1.1 404 Not Found

Defined Under Namespace

Modules: InstanceMethods

Class Method Summary collapse

Class Method Details

.setup(roy) ⇒ Object



23
24
25
# File 'lib/roy/halt.rb', line 23

def self.setup(roy)
  roy.send(:extend, InstanceMethods)
end