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: # custom_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{(?\/\w*)}.match(message)[:path] end # [REQUIRED] Define how you parse query from request message request.query do |message| # For example: # %r{\<3(?.+)}.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