diff --git a/src/ziplineio/html/jinja.py b/src/ziplineio/html/jinja.py
index 9daa08a..7eeeb46 100644
--- a/src/ziplineio/html/jinja.py
+++ b/src/ziplineio/html/jinja.py
@@ -1,5 +1,5 @@
+import inspect
from typing import Any
-
from ziplineio.response import JinjaResponse
from ziplineio.utils import call_handler
@@ -8,8 +8,13 @@ def jinja(env: Any, template_name: str):
template = env.get_template(template_name)
def decorator(handler):
- async def wrapped_handler(*args, **kwargs):
- context = await call_handler(handler, *args, **kwargs)
+ async def wrapped_handler(req, **kwargs):
+ # Pass all arguments directly to the handler
+ sig = inspect.signature(handler)
+ print(f"sig: {sig}")
+ # Filter kwargs to only pass those that the handler expects
+ filtered_kwargs = {k: v for k, v in kwargs.items() if k in sig.parameters}
+ context = await call_handler(handler, req, **filtered_kwargs)
rendered = template.render(context)
return JinjaResponse(rendered)
diff --git a/src/ziplineio/utils.py b/src/ziplineio/utils.py
index 609616c..aa518f2 100644
--- a/src/ziplineio/utils.py
+++ b/src/ziplineio/utils.py
@@ -3,11 +3,9 @@
import asyncio
from typing import Dict
from ziplineio.request import Request
-from ziplineio.response import RawResponse, Response, format_response
+from ziplineio.response import Response
from ziplineio.handler import Handler
from ziplineio.models import ASGIScope
-from ziplineio.exception import BaseHttpException
-from ziplineio import settings
async def call_handler(
@@ -23,13 +21,6 @@ async def call_handler(
except Exception as e:
response = e
- print("EXCEPTION")
- print(e)
- # except Exception as e:
- # print(e)
- # response = BaseHttpException(e, 500)
-
- print(f"response in call handler: {response}")
return response
@@ -37,8 +28,6 @@ async def call_handler(
def parse_scope(scope: ASGIScope) -> Request:
query_string = scope["query_string"].decode("utf-8")
- print(f"query_string: {query_string}")
-
if query_string == "":
query_params = {}
else:
diff --git a/test/test_middleware.py b/test/test_middleware.py
index dbaee19..125c6bf 100644
--- a/test/test_middleware.py
+++ b/test/test_middleware.py
@@ -83,7 +83,7 @@ async def test_handler_with_middleware(req: Request, ctx: dict):
# Call the route
handler, params = self.app._router.get_handler("GET", "/with-middleware")
- response = await call_handler(handler, req, format=True)
+ response = await call_handler(handler, req)
response = format_response(response, settings.DEFAULT_HEADERS)
print(f"response: {response}")
@@ -117,7 +117,7 @@ async def test_handler_with_middleware(req: Request, ctx: dict):
# Call the route
handler, params = self.app._router.get_handler("GET", "/with-middleware")
- response = await call_handler(handler, req, format=False)
+ response = await call_handler(handler, req)
print(response)