mirror of
https://github.com/DefectingCat/candy
synced 2025-07-15 16:51:34 +00:00
add keep-alive default timeout
This commit is contained in:
@ -6,3 +6,4 @@ A tiny web server built with Rust.
|
||||
|
||||
- [ ] HTTP Etag: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag#etag_value
|
||||
- [x] Graceful shutdown
|
||||
- [ ] `keep-alive` timeout setting
|
||||
|
@ -3,6 +3,8 @@ ip = "0.0.0.0"
|
||||
port = 4000
|
||||
# index file name and format
|
||||
index = ["index.html"]
|
||||
# http keep alive timeout
|
||||
keep-alive-time = 75
|
||||
[[host.route]]
|
||||
# route path: GET /
|
||||
location = "/"
|
||||
|
@ -1,4 +1,7 @@
|
||||
use crate::error::Result;
|
||||
use crate::{
|
||||
consts::{keep_alive_timeoutd_efault, KEEP_ALIVE_TIMEOUTD_EFAULT},
|
||||
error::Result,
|
||||
};
|
||||
use std::{collections::BTreeMap, fs};
|
||||
|
||||
use serde::Deserialize;
|
||||
@ -22,6 +25,9 @@ pub struct SettingHost {
|
||||
pub route_map: BTreeMap<String, SettingRoute>,
|
||||
/// Index files format
|
||||
pub index: Vec<String>,
|
||||
/// HTTP keep-alive timeout
|
||||
#[serde(default = "keep_alive_timeoutd_efault")]
|
||||
pub keep_alive: u16,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Clone, Debug)]
|
||||
|
@ -4,3 +4,9 @@ pub const NAME: &str = env!("CARGO_PKG_NAME");
|
||||
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||
pub const OS: &str = env::consts::OS;
|
||||
pub const ARCH: &str = env::consts::ARCH;
|
||||
|
||||
// config defaults
|
||||
pub const KEEP_ALIVE_TIMEOUTD_EFAULT: u16 = 75;
|
||||
pub fn keep_alive_timeoutd_efault() -> u16 {
|
||||
KEEP_ALIVE_TIMEOUTD_EFAULT
|
||||
}
|
||||
|
Reference in New Issue
Block a user