Method: Landline::Handlers::Handler#process

Defined in:
lib/landline/probe/handler.rb

#process(request) ⇒ Boolean

Method callback on successful request navigation. Runs block supplied with object initialization. Request’s #splat and #param are passed to block.

Callback’s returned should be one of viable responses:

  • Response object

  • An array that matches Rack return form

  • An array that matches old (Rack 2.x) return form

  • A string (returned as HTML with code 200)

  • false (bounces the request to next handler)

Parameters:

Returns:

  • (Boolean)

    true if further navigation is possible

Raises:

  • (UncaughtThrowError)

    may raise if die() is called.



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/landline/probe/handler.rb', line 31

def process(request)
  origin, context = get_context(request)

  return reject(request) unless request.path.match?(/^\/?$/)

  response = catch(:break) do
    context.instance_exec(*request.splat,
                          **request.param,
                          &@callback)
  end
  return false unless response

  oresponse = origin.response
  if oresponse and [String, File, IO].include? response.class
    oresponse.body = response
    throw :finish, oresponse
  end
  throw :finish, response
end