Currently my main function, where the server starts looks like this
#[actix_rt::main]
async fn main() -> std::io::Result<()> {
let address = "0.0.0.0:3000";
HttpServer::new(move || {
let app_state = {...some state};
App::new()
.data(app_state)
.wrap(middleware::Logger::default())
.service(network_api::init_service())
})
.bind(address)?
.run()
.await
}
Once the server starts, I want to run one (async) function, to make a request to another server, and that server should respond with another request to this server that just got up and running.
Not sure I see in the documentation anything mentioning a callback function that is run only once on server start.
For example maybe having it in run()
function, like this:
run(|| {
// server started now perform some request or whatever
Client::new().post(&url).json(json_stuff).send().await
})
Edit I think I solved it, will post answer when I can answer my own question