Added support for file download
This commit is contained in:
@@ -20,18 +20,18 @@ from schemas.user_schema import UserSchema
|
||||
|
||||
# AMQP specific imports
|
||||
from amqp.adapter.data_response_factory import AMQResponseFactory
|
||||
from amqp.adapter.cleverthis_service_adapter import CleverThisServiceAdapter, call_cleverthis_get_api, \
|
||||
call_cleverthis_post_put_api, parse_get_url
|
||||
from amqp.service.multipart_parser import CleverMultiPartParser
|
||||
from amqp.adapter.cleverthis_service_adapter import CleverThisServiceAdapter, \
|
||||
parse_get_url, call_cleverthis_api, AMQMessage
|
||||
from amqp.adapter.multipart_parser import CleverMultiPartParser
|
||||
from amqp.config.amq_configuration import AMQConfiguration
|
||||
from amqp.model.model import AMQMessage, AMQResponse
|
||||
from amqp.model.model import AMQResponse
|
||||
from amqp.service.amq_service import AMQService
|
||||
|
||||
|
||||
|
||||
# Suffix for the method name with serialization wrapper, prefer use this one over the orig endpoint
|
||||
PREFERRED_SUFFIX = '_json'
|
||||
|
||||
|
||||
def clone_and_adapt_route(original_route: APIRoute) -> APIRoute:
|
||||
"""
|
||||
Creates a clone of an APIRoute. It checks if there's preferred endpoint with json serialization.
|
||||
@@ -43,7 +43,8 @@ def clone_and_adapt_route(original_route: APIRoute) -> APIRoute:
|
||||
getattr(original_route.endpoint, '__module__'), original_route.endpoint.__name__ + PREFERRED_SUFFIX
|
||||
)
|
||||
# Need to adapt also the path regex to ensure it matches the path in different API versions
|
||||
_new_regex_string = '^.*' + original_route.path_regex.pattern.lstrip('^') # Ensures '^' is only at the start
|
||||
# Ensures the leading '^' is followed by any match and there's no '/' before final '$'
|
||||
_new_regex_string = '^.*' + original_route.path_regex.pattern.lstrip('^').rstrip('/$') +'$'
|
||||
_new_route: APIRoute = APIRoute(
|
||||
path=original_route.path,
|
||||
endpoint=_preferred_endpoint if _preferred_endpoint else original_route.endpoint,
|
||||
@@ -189,7 +190,7 @@ class CleverSwarmAmqpAdapter(CleverThisServiceAdapter):
|
||||
args.update(match.groupdict())
|
||||
args['authenticated_user'] = auth_user
|
||||
# If the path matches, call the corresponding function
|
||||
return await call_cleverthis_post_put_api(
|
||||
return await call_cleverthis_api(
|
||||
message,
|
||||
args,
|
||||
api_method=route.endpoint,
|
||||
@@ -231,7 +232,7 @@ class CleverSwarmAmqpAdapter(CleverThisServiceAdapter):
|
||||
) or parser.form_data[body_param.name]
|
||||
|
||||
|
||||
return await call_cleverthis_post_put_api(
|
||||
return await call_cleverthis_api(
|
||||
message,
|
||||
parser.form_data,
|
||||
api_method=route.endpoint,
|
||||
|
||||
Reference in New Issue
Block a user