def api()

in src/exported_module/api/app.py [0:0]


    def api(self, **path_kwargs):
        try:
            if str(request.path).rstrip('/') in self.paths_without_jwt:
                token_decoded = {}
            else:
                token_decoded = self.authorize()
        except ApplicationException as e:
            return HTTPResponse(
                body=dict(message=e.content),
                status=e.code,
            )

        config_path = str(request.path)
        stage, resource_path = self._split_stage_and_resource(path=config_path)
        if request.url_args:
            # Builds up a proxy-based path.
            for key, value in request.url_args.items():
                # TODO, bug: what if value (which is a value of url args)
                #  is equal, for instance, to api stage???, or to some
                #  part of it. Think about it
                if value in config_path:
                    # Bottle-Routing compatible config path.
                    start = config_path.index(value)
                    prefix = config_path[:start]
                    suffix = config_path[start + len(value):]
                    config_path = prefix + f'<{key}>' + suffix

                    # ApiGateway-2-Lambda compatible request path.
                    start = resource_path.index(value)
                    prefix = resource_path[:start]
                    suffix = resource_path[start + len(value):]
                    resource_path = prefix + '{' + key + '}' + suffix

        endpoint_meta = self.api_config.get(config_path)
        # API-GATEWAY lambda proxy integration event
        event = {
            PARAM_HTTP_METHOD: request.method,
            'headers': dict(request.headers),
            "request_path": '/' + stage.strip('/') + '/' + resource_path.strip(
                '/'),
            "user_id": token_decoded.get(COGNITO_USERNAME),

            'pathParameters': path_kwargs,
            'user_customer': token_decoded.get('cognito:customer'),
            'action': endpoint_meta.get('action')
        }
        if request.method == 'GET':
            event['query'] = dict(querystring=dict(request.query))
            event['body'] = None
        else:
            event['body'] = json.loads(request.body.read().decode())

        lambda_module = self.lambda_module_mapping.get(
            endpoint_meta.get('lambda_name'))
        try:
            response = lambda_module.lambda_handler(event=event,
                                                    context=RequestContext())
            return HTTPResponse(
                body=response.get('body'),
                status=response.get('statusCode'),
                headers=response.get('headers')
            )
        except ApplicationException as e:
            return HTTPResponse(
                body={'message': e.content},
                status=e.code
            )