Skip to content

Commit 8cdf2a5

Browse files
committed
Fix issue #22: Add request parameter injection and bump version to 0.10.3
- Fixed request parameter injection in dispatch.py for both sync and async handlers - Fixed JWT instance lookup in jwt.py (was using request._app instead of request.app) - All JWT authentication endpoints now work correctly - Bumped version to 0.10.3 in Cargo.toml, pyproject.toml, and __init__.py Resolves #22
1 parent 328d6d4 commit 8cdf2a5

5 files changed

Lines changed: 21 additions & 5 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "bustapi_core"
3-
version = "0.10.2"
3+
version = "0.10.3"
44
edition = "2021"
55

66
[lib]

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "maturin"
44

55
[project]
66
name = "bustapi"
7-
version = "0.10.2"
7+
version = "0.10.3"
88
description = "High-performance Python web framework with Rust backend"
99
authors = [
1010
{name = "GrandpaEJ", email = ""}

python/bustapi/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def hello():
2222
import sys
2323
from http import HTTPStatus
2424

25-
__version__ = "0.10.2"
25+
__version__ = "0.10.3"
2626
__author__ = "BustAPI" # with GrandpaEJ
2727
__email__ = ""
2828

python/bustapi/dispatch.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ def wrapper(rust_request, path_params=None):
160160
if name not in kwargs and name in request.args:
161161
kwargs[name] = request.args.get(name)
162162

163+
# Inject request object if handler expects it
164+
if "request" in expected_args:
165+
kwargs["request"] = request
166+
163167
call_kwargs = (
164168
kwargs
165169
if has_kwargs
@@ -207,6 +211,10 @@ def wrapper(rust_request, path_params=None):
207211
if name not in kwargs and name in request.args:
208212
kwargs[name] = request.args.get(name)
209213

214+
# Inject request object if handler expects it
215+
if "request" in expected_args:
216+
kwargs["request"] = request
217+
210218
call_kwargs = (
211219
kwargs
212220
if has_kwargs
@@ -323,6 +331,10 @@ async def wrapper(rust_request):
323331
if name not in kwargs and name in request.args:
324332
kwargs[name] = request.args.get(name)
325333

334+
# Inject request object if handler expects it
335+
if "request" in expected_args:
336+
kwargs["request"] = request
337+
326338
call_kwargs = (
327339
kwargs
328340
if has_kwargs
@@ -369,6 +381,10 @@ async def wrapper(rust_request):
369381
if name not in kwargs and name in request.args:
370382
kwargs[name] = request.args.get(name)
371383

384+
# Inject request object if handler expects it
385+
if "request" in expected_args:
386+
kwargs["request"] = request
387+
372388
call_kwargs = (
373389
kwargs
374390
if has_kwargs

python/bustapi/jwt.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,8 @@ def _get_jwt() -> JWT:
185185
return _jwt_instance
186186

187187
# Try to get from current app
188-
if request and hasattr(request, "_app") and request._app:
189-
jwt_ext = request._app.extensions.get("jwt")
188+
if request and hasattr(request, "app") and request.app:
189+
jwt_ext = request.app.extensions.get("jwt")
190190
if jwt_ext:
191191
return jwt_ext
192192

0 commit comments

Comments
 (0)