Sha256: b8017343f9d6c148ff8344607cfa75e2606234167adcfdc226166d8d8188abfa

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

Toycol::Protocol.define(:PROTOCOL_NAME) do
  # For example
  #   client would send:
  #     quack, quack /posts<3user_id=1
  #   server would interpret client message:
  #     GET /posts?user_id=1


  # [OPTIONAL] You can define your additional request methods:
  # For example:
  # additional_request_methods OTHER

  # [OPTIONAL] You can define your own response status code:
  # For example:
  # define_status_codes(
  #   600 => "I'm afraid you are not a duck..."
  # )

  # [REQUIRED] Define how you parse request path from request message
  request.path do |message|
    # For example:
    # %r{(?<path>\/\w*)}.match(message)[:path]
  end

  # [REQUIRED] Define how you parse query from request message
  request.query do |message|
    # For example:
    # %r{\<3(?<query>.+)}.match(message) { |m| m[:query] }
  end

  # [REQUIRED] Define how you parse query from request message
  request.http_method do |message|
    # For example:
    # case message.scan(/quack/).size
    # when 2 then "GET"
    # else "OTHER"
    # end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
toycol-0.3.0 lib/toycol/templates/protocol.txt