Sha256: 248bc9dcb8dbe834db62c16506bd1c13fdfc152a2a660abf643679bd11bfaa4b
Contents?: true
Size: 1.02 KB
Versions: 2
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: # 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{(?<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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
toycol-1.0.0 | lib/toycol/templates/protocol.txt |
toycol-0.3.1 | lib/toycol/templates/protocol.txt |