dioxus
dioxus copied to clipboard
add ability to pass external state to fullstack server
Specific Demand
currently, the fullstack template uses a basic LaunchBuidler
setup and calls launch
on it to start up the backend server with the ability to server SSR'ed Dioxus pages. this works great. however, this functionality is very limiting since the user is unable to supply extra layers, extensions, and data to the (in my case) Axum server that ends up running. The current solution is to take the code that is run in the launch
method's source code, bring that in to your project, and work from there. this works fine but is less than ideal in terms of future upgrades to the library. it'd be great to be able to supply data, extensions, layers, etc. to the LaunchBuilder
as an abstraction from needing to fuss with the underlying Dioxus server setup.
Implement Suggestion
it could be something relatively simple as adding methods to the LaunchBuilder
struct for adding each of these to the internal server_cfg
and then on launch
, add them into the correct place if they have been set. however, this might not be super scalable since each server library might have their own specific implementation for Data vs Extention vs etc. however, each method would theoretically be easy to write. maintainability long term could be an issue.
We could use the dioxus server context which is a version of context provided to handlers that works with all backends
We could use the dioxus server context which is a version of context provided to handlers that works with all backends
the thought being that instead of making it server specific, it becomes just something we do in Dioxus instead? that'd be a scalable way to do it.