Skip to content

Commit 121c080

Browse files
authored
Embetter @inertia decorator (#77)
* Don't trampoline through `render()` in `@inertia` * Change `@inertia` decorator type-check to look at response-ness * Rename `inner` so it's easier to understand in stack traces
1 parent ea74f4a commit 121c080

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

inertia/http.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -237,15 +237,15 @@ def clear_history(request):
237237
def inertia(component):
238238
def decorator(func):
239239
@wraps(func)
240-
def inner(request, *args, **kwargs):
240+
def process_inertia_response(request, *args, **kwargs):
241241
props = func(request, *args, **kwargs)
242242

243-
# if something other than a dict is returned, the user probably wants to return a specific response
244-
if not isinstance(props, dict):
243+
# if a response is returned, return it
244+
if isinstance(props, HttpResponse):
245245
return props
246246

247-
return render(request, component, props)
247+
return InertiaResponse(request, component, props)
248248

249-
return inner
249+
return process_inertia_response
250250

251251
return decorator

0 commit comments

Comments
 (0)