How to set http timeouts using axum (based on hyper)?

Viewed 32

I'm coming from Golang where I can simply use http.Server struct for timeout options like:

func start() {
  httpServer := &http.Server{
    ReadTimeout:  "30s",
    WriteTimeout: "1h",
    //...
  }

  err = httpServer.ListenAndServe()
}

I'm using axum { version = "0.5.16", features = ["json"] } right now and I would like to set these timeouts but I cannot find out how.

Can you help me?

I know axum is using hyper, can you help me understand how to do this?

I'm using the below code:

axum::Server::bind(&addr)
  .serve(app.into_make_service())
  .with_graceful_shutdown(shutdown_signal())
  .await
  .unwrap();
0 Answers
Related