Central app controller for back end when using SSR (actix or axum) #2026
-
I am fairly new to rust and SSR I normally develop back end applications in golang using hexagonal architechture with ports and injection keeping everything separated and modular. for instance if I have a back end with some http endpoints I would inject the application into the http implementation and I would have a reference to my application from there. type App struct {
db *DB
}
type HttpEdge struct {
app App
}
func NewHttpEdge(app *App) *HttpEdge {
return &HttpEdge{ app }
}
func (api *HttpEdge) rootEndpoint(w http.ResponseWriter, r *http.Response) {
// Here I can access my app
api.app.SomeFunction()
} My question is how can I do something like this with axtix or axum? I saw in the "auth with session example" that an I would like to use this for calling grpc services and maybe for some auththentication logic as well. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I think you might be looking for something like Axum's I think this might be a more general Rust/Axum/Actix question though so you may also have luck asking in communities dedicated to those. |
Beta Was this translation helpful? Give feedback.
I think you might be looking for something like Axum's
State
or Actix'sData
, both of which allow a kind of dependency injection, but to be fair I have never heard the term hexagonal architecture, don't know Go, and have no real idea what you're talking about.I think this might be a more general Rust/Axum/Actix question though so you may also have luck asking in communities dedicated to those.