Skip to content
This repository was archived by the owner on Mar 18, 2019. It is now read-only.
This repository was archived by the owner on Mar 18, 2019. It is now read-only.

Match with a proc #8

@lasseebert

Description

@lasseebert

It might be a good feature to be able to match with a proc.

Example matching a Rack response:

response = app.call(env)
kase response do
  on(proc { |status, _headers, _bodies| (200...300).include?(status) } ) do |_status, _headers, bodies|
    ok_response(bodies.first)
  end
  on(400) { |_headers, bodies| parse_error(bodies.first) }
  on(500) { |headers, bodies| log_error(headers, bodies) }
end

Or we could allow matching with === with match instead of on. The above would then be rewritten to:

response = app.call(env)
kase response do
  match(200...300) { |_status, _headers, bodies| ok_response(bodies.first) }
  on(400) { |_headers, bodies| parse_error(bodies.first) }
  on(500) { |headers, bodies| log_error(headers, bodies) }
end

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions