@@ -174,7 +174,7 @@ async def add_security_headers(request: Request, call_next):
174
174
175
175
176
176
if is_development (config_instance = config_instance ):
177
- app .add_middleware (TrustedHostMiddleware , allowed_hosts = ["gateway. eod-stock-api.site " , "localhost" , "127.0.0.1" ])
177
+ app .add_middleware (TrustedHostMiddleware , allowed_hosts = ["eod-stock-api.local " , "localhost" , "127.0.0.1" ])
178
178
else :
179
179
app .add_middleware (TrustedHostMiddleware , allowed_hosts = ["master-gateway.eod-stock-api.site" , "gateway.eod-stock-api.site" ])
180
180
@@ -254,7 +254,7 @@ async def validate_request_middleware(request, call_next):
254
254
# You can modify the request here, or perform any other
255
255
# pre-processing that you need.
256
256
# allowedPaths = ["/", "/api/", "/redoc", "/docs", "/_admin/"]
257
-
257
+ app_logger . info ( "validate_request" )
258
258
async def compare_tokens ():
259
259
"""will check headers to see if the request comes from cloudflare"""
260
260
_cf_secret_token = request .headers .get ('X-SECRET-TOKEN' )
@@ -281,7 +281,7 @@ async def compare_tokens():
281
281
"message" : "Request Contains Suspicious patterns cannot continue" }
282
282
response = JSONResponse (content = mess , status_code = 404 )
283
283
return response
284
-
284
+ app_logger . info ( f"Request is not malicios" )
285
285
if path .startswith ("/_admin" ) or path .startswith ("/redoc" ) or path .startswith ("/docs" ) or path .startswith (
286
286
"/static" ):
287
287
app_logger .info ("starts with admin going in " )
@@ -293,6 +293,7 @@ async def compare_tokens():
293
293
response = await call_next (request )
294
294
295
295
elif is_development (config_instance = config_instance ):
296
+ app_logger .info (f"Development" )
296
297
response = await call_next (request )
297
298
298
299
elif not await compare_tokens ():
@@ -443,15 +444,17 @@ async def v1_gateway(request: Request, path: str):
443
444
444
445
api_key : dict = request .query_params .get ('api_key' )
445
446
_path = f"/api/v1/{ path } "
447
+ app_logger .info (f"Gateway" )
446
448
await create_take_credit_args (api_key = api_key , path = _path )
447
449
448
450
api_urls = [f'{ api_server_url } /api/v1/{ path } ' for api_server_url in remote_servers .healthy_server_urls ]
449
451
450
452
# Will Take at least six second on the cache if it finds nothing will return None
451
453
# need an improved get timeout for the articles
452
454
tasks = [redis_cache .get (key = api_url , timeout = 60 * 5 ) for api_url in api_urls ]
455
+ app_logger .info ("fetching responses" )
453
456
cached_responses = await asyncio .gather (* tasks )
454
-
457
+ app_logger . info ( "fetched records" )
455
458
for i , response in enumerate (cached_responses ):
456
459
if response and response .get ('payload' ):
457
460
app_logger .info (msg = f"Found cached response from { api_urls [i ]} " )
0 commit comments