Sha256: eddad7bb391b641d5e3a8e4d3b28bbdfe7c4a27c58488b28d2f8a1cca8721e64

Contents?: true

Size: 473 Bytes

Versions: 4

Compression:

Stored size: 473 Bytes

Contents

# frozen_string_literal: true

Toycol::Protocol.define(:duck) do
  custom_status_codes(
    600 => "I'm afraid you are not a duck..."
  )
  additional_request_methods "OTHER"

  request.path do |message|
    %r{(?<path>/\w*)}.match(message)[:path]
  end

  request.query do |message|
    /\?(?<query>.+)/.match(message) { |m| m[:query] }
  end

  request.http_method do |message|
    case message.scan(/quack/).size
    when 2 then "GET"
    else "OTHER"
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
toycol-0.2.2 examples/duck/Protocolfile.duck
toycol-0.2.1 examples/duck/Protocolfile.duck
toycol-0.2.0 examples/duck/Protocolfile.duck
toycol-0.1.0 examples/duck/Protocolfile.duck