Skip to content
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

Provide custom state in file_and_error_handler #3408

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

spencewenski
Copy link
Contributor

@spencewenski spencewenski commented Dec 24, 2024

The file_and_error_handler provided by leptos_axum does not provide the app's custom state in the context. This means that when the fallback handler tries to render the app, the app will not be able to access the custom state (and will panic if it uses expect_context).

The handler defined by file_and_error_handler has access to the custom state from Axum, so we can pass the custom state from Axum into the Leptos handler using the additional_context parameter of handle_response_inner.

I think this might technically be a semver breaking change because we're adding constraints to the S type parameter. However, I think it should be fine because any custom state used with this method would need to satisfy these constraints to be used in the first place (e.g., in the LeptosRoutes trait). However, I'll leave it up to you to decide if a version bump is needed, or if there's a way to do this without requiring changing the type constraints.

The `file_and_error_handler` provided by leptos_axum does not provide
the app's custom state in the context. This means that when the fallback
handler tries to render the app, the app will not be able to access the
custom state (and will panic if it uses `expect_context`).

The handle defined by `file_and_error_handler` has access to the custom
state from Axum, so we can pass the custom state from Axum into the
Leptos handler using the `additional_context` parameter of
`handle_response_inner`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant