import json
from urllib.parse import parse_qs
from cgi import parse_header


def form_params_middleware(func):
    def wrapper(request):
        ctype, pdict = parse_header(request.headers.get('Content-Type', ''))
        if ctype == "application/x-www-form-urlencoded":
            request.form_params = {}
            for key, value in parse_qs(request.body.decode("utf-8")).items():
                if len(value) == 1:
                    request.form_params[key] = value[0]
                else:
                    request.form_params[key] = value
        return func(request)
    return wrapper

def get_params_middleware(func):
    def wrapper(request):
        request.get_params = {}
        for key, value in parse_qs(request.query_string.decode("utf-8")).items():
            if len(value) == 1:
                request.get_params[key] = value[0]
            else:
                request.get_params[key] = value
        return func(request)
    return wrapper

@@ -5,16 +5,78 @@
 rt json%0A
+import functools%0A%0Afrom anillo.utils.common import merge_dicts%0A
 from url
@@ -136,16 +136,21 @@
 r%0A%0A%0Adef 
+wrap_
 form_par
@@ -152,34 +152,319 @@
 m_params
-_middleware
+(func):%0A    %22%22%22%0A    A middleware that parses the url-encoded body and attach%0A    the result to the request %60form_params%60 attribute.%0A%0A    This middleware also merges the parsed value with the existing%0A    %60params%60 attribute in same way as %60wrap_query_params%60 is doing.%0A    %22%22%22%0A%0A    @functools.wraps
 (func)
-:
 %0A    def
@@ -624,37 +624,24 @@
             
-request.form_
 params = %7B%7D%0A
@@ -770,37 +770,24 @@
             
-request.form_
 params%5Bkey%5D 
@@ -819,32 +819,148 @@
   else:%0A        
+            params%5Bkey%5D = value%0A%0A            request.params = merge_dicts(getattr(request, %22params%22, None), params)%0A
             requ
@@ -970,37 +970,33 @@
 .form_params
-%5Bkey%5D = value
+ = params
 %0A        ret
@@ -1037,40 +1037,347 @@
 er%0A%0A
+%0A
 def 
-get_params_middleware
+wrap_query_params(func):%0A    %22%22%22%0A    A middleware that parses the urlencoded params from the querystring%0A    and attach it to the request %60query_params%60 attribute.%0A%0A    This middleware also merges the parsed value with the existing%0A    %60params%60 attribute in same way as %60wrap_form_params%60 is doing.%0A    %22%22%22%0A%0A    @functools.wraps
 (func)
-:
 %0A   
@@ -1403,36 +1403,24 @@
 t):%0A        
-request.get_
 params = %7B%7D%0A
@@ -1545,36 +1545,24 @@
             
-request.get_
 params%5Bkey%5D 
@@ -1610,20 +1610,8 @@
     
-request.get_
 para
@@ -1625,16 +1625,134 @@
  = value
+%0A%0A        request.params = merge_dicts(getattr(request, %22params%22, None), params)%0A        request.query_params = params
 %0A       

Improve the params parsing and corresponding renames.