Sha256: fa42c1da861c73ae993e5ce2d0d1a11dd9c92b9be8377f137f8693d5c341b3f3
Contents?: true
Size: 1003 Bytes
Versions: 23
Compression:
Stored size: 1003 Bytes
Contents
# frozen_string_literal: true # 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
23 entries across 23 versions & 1 rubygems