Create an Http
class to convert the following string into a Hash
with the given rules.
"market[name]=Cap Hill Market&market[description]=A good place to buy produce"
- Separate each element on the
&
characters. - Separate key and value on the
=
character [*]
indicates a hash as a value, the word preceding the[*]
is the key to the value and the word in the[*]
is a key within the nested hash.
Example:
{market: {name: "Cap Hill Market", description: "A good place to buy produce"}}
"market[name]=Cap%20Hill%20Market&market[description]=A%20good%20place%20to%20buy%20produce"
- Rules from Bronze
- Convert
%20
into a space character
Create a nested hash by separating the following into hashes
"market[name]=Cap%20Hill%20Market&market[description]=A%20good%20place%20to%20buy%20produce&market[vendors_attributes][][name]=Jules%20Produce"
- Rules from Bronze and Silver
- An empty
[]
indicates an Array as a value. the word preceding the[]
is the key to the Array the word after the=
will be added to the array.
GET /markets HTTP/1.1
User-Agent: curl/7.30.0
Host: localhost:3000
Content-Length: 141
Accept: */*
market[name]=Cap%20Hill%20Market&market[description]=A%20good%20place%20to%20buy%20produce&market[vendors_attributes][][name]=Jules%20Produce
- Rules from Bronze, Silver, and Gold
- Seperate and parse the hash from the rest of the HTTP text
- Add additional attributes of
method
andpath
to the class and parse those out of the request ("GET" & "/markets")