Skip to content

Embetter @inertia decorator #77

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions inertia/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,15 +237,15 @@ def clear_history(request):
def inertia(component):
def decorator(func):
@wraps(func)
def inner(request, *args, **kwargs):
def process_inertia_response(request, *args, **kwargs):
props = func(request, *args, **kwargs)

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

return render(request, component, props)
return InertiaResponse(request, component, props)

return inner
return process_inertia_response

return decorator
Loading