Skip to content
Snippets Groups Projects
Commit 3a080227 authored by codecraft's avatar codecraft :crocodile:
Browse files

Add some documentation

parent af4ab2e3
No related branches found
No related tags found
1 merge request!1Initial feature merge
......@@ -45,6 +45,7 @@ mod test {
];
let mut wrong = vec!["GET / HTTP/1.1".to_string()];
assert_eq!(None, extract_cookies_from_vec(&mut wrong));
let cookies = extract_cookies_from_vec(&mut request_vec);
assert_eq!(right_finished_vec, request_vec);
......
......@@ -65,6 +65,18 @@ impl<'a> Config {
}
self
}
/// # Launches/Starts the webserver
/// Launches a Webserver Configuration
///
/// Is Async
///
/// Is Blocking -> Can be interrupted with ^C
///
/// # Panics
/// Panics if there are no Mountpoints in the Confiuration to lauch, as well as when the there
/// is no interrupt signal
///
/// Panics if .
pub async fn launch(self) {
println!("Server launched from http://{}", self.address.local_addr().unwrap());
let mut sigint = signal(SignalKind::interrupt()).unwrap();
......@@ -82,6 +94,22 @@ impl<'a> Config {
}
}
}
/// # Creates a Webserver Config which can be launched with the launch function
/// Takes the IP and Port as an argument
///
/// Prints out the configuration test
///
/// Is async
///
/// # Example
/// ```
/// async fn example() {
/// let _ = http::build("127.0.0.1:8000");
/// }
/// ```
/// # Panics
/// Panics if the IP is not bindable, or other forms of system errors or it's not a valid
/// IP-Address
pub async fn build(ip: &str) -> Config {
let listener = if let Ok(listener) = TcpListener::bind(ip).await {
listener
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment