Clean up Advoware proxy steps: remove redundant /api/ from paths, simplify method-specific code, and fix DELETE json_data

This commit is contained in:
root
2025-10-19 16:03:11 +00:00
parent bed1008337
commit 1f893812b2
5 changed files with 8 additions and 39 deletions

View File

@@ -4,7 +4,7 @@ config = {
'type': 'api',
'name': 'Advoware Proxy DELETE',
'description': 'Universal proxy for Advoware API (DELETE)',
'path': '/api/advoware/proxy/delete',
'path': '/advoware/proxy',
'method': 'DELETE',
'emits': [],
'flows': ['advoware']
@@ -20,7 +20,7 @@ async def handler(req, context):
advoware = AdvowareAPI(context)
method = 'DELETE' # Feste Methode für diesen Step
params = {k: v for k, v in req.get('queryParams', {}).items() if k != 'endpoint'}
json_data = req.get('body')
json_data = None
context.logger.info(f"Proxying request to Advoware: {method} {endpoint}")
result = await advoware.api_call(endpoint, method=method, params=params, json_data=json_data)

View File

@@ -4,7 +4,7 @@ config = {
'type': 'api',
'name': 'Advoware Proxy GET',
'description': 'Universal proxy for Advoware API (GET)',
'path': '/api/advoware/proxy',
'path': '/advoware/proxy',
'method': 'GET',
'emits': [],
'flows': ['advoware']
@@ -18,9 +18,9 @@ async def handler(req, context):
return {'status': 400, 'body': {'error': 'Endpoint required as query param'}}
advoware = AdvowareAPI(context)
method = req.get('method', 'GET')
method = 'GET'
params = {k: v for k, v in req.get('queryParams', {}).items() if k != 'endpoint'}
json_data = req.get('body') if method in ['POST', 'PUT', 'PATCH'] else None
json_data = None
context.logger.info(f"Proxying request to Advoware: {method} {endpoint}")
result = await advoware.api_call(endpoint, method=method, params=params, json_data=json_data)
@@ -28,4 +28,4 @@ async def handler(req, context):
return {'status': 200, 'body': {'result': result}}
except Exception as e:
context.logger.error(f"Proxy error: {e}")
return {'status': 500, 'body': {'error': 'Internal server error', 'details': str(e)}}
return {'status': 500, 'body': {'error': 'Internal server error', 'details': str(e)}}

View File

@@ -4,7 +4,7 @@ config = {
'type': 'api',
'name': 'Advoware Proxy POST',
'description': 'Universal proxy for Advoware API (POST)',
'path': '/api/advoware/proxy/post',
'path': '/advoware/proxy',
'method': 'POST',
'emits': [],
'flows': ['advoware']

View File

@@ -4,7 +4,7 @@ config = {
'type': 'api',
'name': 'Advoware Proxy PUT',
'description': 'Universal proxy for Advoware API (PUT)',
'path': '/api/advoware/proxy/put',
'path': '/advoware/proxy',
'method': 'PUT',
'emits': [],
'flows': ['advoware']