def handleControllerMethod(args, kwargs, contentType, resourceInstance, resourceInstanceMethod, requestHeaderClass, requestParamClass, requestClass, logRequest, muteStacktraceOnBusinessRuleException): requestBodyAsJson = {} if resourceInstanceMethod.__name__ in OpenApiManager.ABLE_TO_RECIEVE_BODY_LIST and requestClass: requestBodyAsJson = getRequestBodyAsJson(contentType, requestClass) if Serializer.requestBodyIsPresent(requestBodyAsJson): requestBodyAsJsonSerialized = Serializer.convertFromJsonToObject( requestBodyAsJson, requestClass) args = getArgsWithSerializerReturnAppended( args, requestBodyAsJsonSerialized) headers = FlaskUtil.addToKwargs(FlaskUtil.KW_HEADERS, requestHeaderClass, FlaskUtil.safellyGetHeaders(), kwargs) query = FlaskUtil.addToKwargs(FlaskUtil.KW_PARAMETERS, requestParamClass, FlaskUtil.safellyGetArgs(), kwargs) try: if resourceInstance.logRequest or logRequest: log.prettyJson( resourceInstanceMethod, '[CONTROLLER] Request', { 'headers': headers, # 'query': FlaskUtil.addToKwargs(FlaskUtil.KW_PARAMETERS, requestParamClass, FlaskUtil.safellyGetArgs(), kwargs), ###- safellyGetUrl() returns query param 'body': requestBodyAsJson }, condition=True, logLevel=log.INFO) except Exception as exception: log.failure(innerResourceInstanceMethod, 'Not possible to log request properly', exception) return validateAndReturnResponse( handleAdditionalResponseHeadersIfNeeded( resourceInstanceMethod(resourceInstance, *args[1:], **kwargs)))
def captureTokenFromRequestHeader(self): return FlaskUtil.safellyGetHeaders().get(self.headerName)
def getRequestHeaders(self): return FlaskUtil.safellyGetHeaders()