mirror of
https://github.com/amigan/rustypaste-pretty.git
synced 2024-11-21 11:59:48 -05:00
feat(config): support setting the timeout for HTTP requests
This commit is contained in:
parent
fda6f91211
commit
94516c95bb
3 changed files with 9 additions and 1 deletions
|
@ -6,6 +6,7 @@ address="127.0.0.1:8000"
|
||||||
#workers=4
|
#workers=4
|
||||||
max_content_length="10MB"
|
max_content_length="10MB"
|
||||||
upload_path="./upload"
|
upload_path="./upload"
|
||||||
|
timeout="30s"
|
||||||
|
|
||||||
[paste]
|
[paste]
|
||||||
random_url = { enabled = true, type = "petname", words = 2, separator = "-" }
|
random_url = { enabled = true, type = "petname", words = 2, separator = "-" }
|
||||||
|
|
|
@ -35,6 +35,9 @@ pub struct ServerConfig {
|
||||||
pub max_content_length: Byte,
|
pub max_content_length: Byte,
|
||||||
/// Storage path.
|
/// Storage path.
|
||||||
pub upload_path: PathBuf,
|
pub upload_path: PathBuf,
|
||||||
|
/// Request timeout.
|
||||||
|
#[serde(default, with = "humantime_serde")]
|
||||||
|
pub timeout: Option<Duration>,
|
||||||
/// Authentication token.
|
/// Authentication token.
|
||||||
pub auth_token: Option<String>,
|
pub auth_token: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,11 @@ async fn main() -> IoResult<()> {
|
||||||
// Create a HTTP server.
|
// Create a HTTP server.
|
||||||
let mut http_server = HttpServer::new(move || {
|
let mut http_server = HttpServer::new(move || {
|
||||||
let http_client = ClientBuilder::default()
|
let http_client = ClientBuilder::default()
|
||||||
.timeout(Duration::from_secs(30))
|
.timeout(
|
||||||
|
server_config
|
||||||
|
.timeout
|
||||||
|
.unwrap_or_else(|| Duration::from_secs(30)),
|
||||||
|
)
|
||||||
.disable_redirects()
|
.disable_redirects()
|
||||||
.finish();
|
.finish();
|
||||||
App::new()
|
App::new()
|
||||||
|
|
Loading…
Reference in a new issue