def get_request_parameters(self, *args, **kwargs) -> RequestParameters: req = args[-1] # TODO : Check # TODO : move this code to check_json # same idea as in : https://bottlepy.org/docs/dev/_modules/bottle.html#BaseRequest.json if req.content_type in ("application/json", "application/json-rpc"): try: json_body = req.json_body # TODO - G.M - 2019-06-06 - raise exception if not correct , # return 400 if uncorrect instead ? except Exception: json_body = {} else: json_body = {} forms_parameters = {} files_parameters = {} for name, item in req.POST.items(): if isinstance(item, cgi.FieldStorage): files_parameters[name] = item else: forms_parameters[name] = item return RequestParameters( path_parameters=req.matchdict, query_parameters=req.GET, body_parameters=json_body, form_parameters=req.POST, header_parameters=LowercaseKeysDict([ (k.lower(), v) for k, v in req.headers.items() ]), files_parameters=files_parameters, )
def get_request_parameters(self, *args, **kwargs) -> RequestParameters: return RequestParameters( path_parameters=self.path_parameters, query_parameters=self.query_parameters, body_parameters=self.body_parameters, form_parameters=self.form_parameters, header_parameters=self.header_parameters, files_parameters=self.files_parameters, )
def get_request_parameters(self, *args, **kwargs) -> RequestParameters: from flask import request return RequestParameters( path_parameters=request.view_args, query_parameters=request.args, # TODO: Check body_parameters=request.get_json(), # TODO: Check form_parameters=request.form, header_parameters=LowercaseKeysDict( [(k.lower(), v) for k, v in request.headers.items()] ), files_parameters=request.files, )
def get_request_parameters(self, *args, **kwargs) -> RequestParameters: path_parameters = dict(bottle.request.url_args) query_parameters = MultiDict(bottle.request.query.allitems()) body_parameters = dict(bottle.request.json or {}) form_parameters = MultiDict(bottle.request.forms.allitems()) header_parameters = LowercaseKeysDict( [(k.lower(), v) for k, v in bottle.request.headers.items()] ) files_parameters = dict(bottle.request.files) return RequestParameters( path_parameters=path_parameters, query_parameters=query_parameters, body_parameters=body_parameters, form_parameters=form_parameters, header_parameters=header_parameters, files_parameters=files_parameters, )