Skip to content

Commit 5e4cfc5

Browse files
committed
adds warning
1 parent f2a8f0b commit 5e4cfc5

File tree

2 files changed

+14
-16
lines changed

2 files changed

+14
-16
lines changed

services/web/server/src/simcore_service_webserver/application_settings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ class ApplicationSettings(BaseCustomSettings, MixinLoggingSettings):
108108
env=["WEBSERVER_LOGLEVEL", "LOG_LEVEL", "LOGLEVEL"],
109109
# NOTE: suffix '_LOGLEVEL' is used overall
110110
)
111+
111112
WEBSERVER_LOG_FORMAT_LOCAL_DEV_ENABLED: bool = Field(
112113
default=False,
113114
env=["WEBSERVER_LOG_FORMAT_LOCAL_DEV_ENABLED", "LOG_FORMAT_LOCAL_DEV_ENABLED"],

services/web/server/src/simcore_service_webserver/products/_middlewares.py

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import logging
2+
import textwrap
23
from collections import OrderedDict
34

45
from aiohttp import web
@@ -43,7 +44,7 @@ def _discover_product_by_request_header(request: web.Request) -> str | None:
4344
return None
4445

4546

46-
def _get_diagnose_msg(request: web.Request):
47+
def _get_debug_msg(request: web.Request):
4748
return "\n".join(
4849
[
4950
f"{request.url=}",
@@ -56,9 +57,6 @@ def _get_diagnose_msg(request: web.Request):
5657
)
5758

5859

59-
_INCLUDE_PATHS: set[str] = {"/static-frontend-data.json", "/socket.io/"}
60-
61-
6260
@web.middleware
6361
async def discover_product_middleware(request: web.Request, handler: Handler):
6462
"""
@@ -71,8 +69,9 @@ async def discover_product_middleware(request: web.Request, handler: Handler):
7169
if (
7270
# - API entrypoints
7371
# - /static info for front-end
72+
# - socket-io
7473
request.path.startswith(f"/{API_VTAG}")
75-
or request.path in _INCLUDE_PATHS
74+
or request.path in {"/static-frontend-data.json", "/socket.io/"}
7675
):
7776
request[RQ_PRODUCT_KEY] = (
7877
_discover_product_by_request_header(request)
@@ -83,22 +82,20 @@ async def discover_product_middleware(request: web.Request, handler: Handler):
8382
else:
8483
# - Publications entrypoint: redirections from other websites. SEE studies_access.py::access_study
8584
# - Root entrypoint: to serve front-end apps
86-
# request.path.startswith("/study/")
87-
# or request.path.startswith("/view")
88-
# or request.path == "/" )
85+
assert ( # nosec
86+
request.path.startswith("/dev/")
87+
or request.path.startswith("/study/")
88+
or request.path.startswith("/view")
89+
or request.path == "/"
90+
)
8991
request[RQ_PRODUCT_KEY] = _discover_product_by_hostname(
9092
request
9193
) or _get_default_product_name(request.app)
9294

93-
# FIXME: session[product]
94-
# if product_session := get_session(request).get('product_name'):
95-
# assert get_product_name(request) == product_session
96-
95+
# TODO: remove this!!!
9796
_logger.warning(
98-
"\n%s\n%s\n%s\n",
99-
"------------------TESTING-------------------",
100-
_get_diagnose_msg(request),
101-
"-------------------------------------------",
97+
"Product middleware result: \n%s\n",
98+
textwrap.indent(_get_debug_msg(request), " "),
10299
)
103100
assert request[RQ_PRODUCT_KEY] # nosec
104101

0 commit comments

Comments
 (0)