Sha256: 28857713988e6130c2bb26a34b05874da1154bb0b01cad4230eb4d54ca939324
Contents?: true
Size: 972 Bytes
Versions: 13
Compression:
Stored size: 972 Bytes
Contents
# This is an example of a handler that can load and generate www-url-encoded payloads. # Note that if you use your API to pass nil values for attributes as a way to unset their # values, this handler will not work (as there isn't necessarily a defined "null" value in # this encoding (although you can probably define how to encode/decode it and use it as such) # Use at your own risk. module Praxis module Handlers class WWWForm def initialize require 'rack' # superfluous, but might as well be safe end # Parse a URL-encoded WWW form into structured data. def parse(entity) ::Rack::Utils.parse_nested_query(entity) end # Generate a URL-encoded WWW form from structured data. Not implemented since this format # is not very useful for a response body. def generate(structured_data) return nil if structured_data.nil? URI.encode_www_form(structured_data) end end end end
Version data entries
13 entries across 13 versions & 1 rubygems