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

Switch axum Extension usage to State #761

Merged
merged 1 commit into from
Jan 10, 2023

Conversation

svix-andor
Copy link
Contributor

Motivation

State is the new, type-safe way of passing around global state between handlers in axum. Extensions were only resolved at runtime, therefore if you forgot to pass an extension with layer() it'd only fail at runtime. With State a handler can't be registered on the router if its state can't pass all the required parameters to the handler.

Solution

Replace all usage of Extension with state.

Closes #726

server/svix-server/src/lib.rs Outdated Show resolved Hide resolved
server/svix-server/src/v1/endpoints/auth.rs Outdated Show resolved Hide resolved
svix-gabriel
svix-gabriel previously approved these changes Jan 10, 2023
Copy link
Contributor

@svix-gabriel svix-gabriel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should just make sure to squash the commits before merging (might have to force push, in which case I can reapprove).

State is the new, type-safe way of passing around global state between
handlers.
@svix-gabriel svix-gabriel merged commit ef43606 into main Jan 10, 2023
@svix-gabriel svix-gabriel deleted the andor/switch-axum-extension-to-state branch January 10, 2023 18:35
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.

Server: change use of Axum Extension with State
2 participants