Skip to content

Commit 9a8c99f

Browse files
committed
web: Document server
1 parent 1ac0d0e commit 9a8c99f

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

rust-code-analysis-web/src/web/server.rs

+26
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,32 @@ async fn ping() -> HttpResponse {
218218
HttpResponse::Ok().body(())
219219
}
220220

221+
/// Runs an HTTP Server which provides a series of services.
222+
///
223+
/// Each service corresponds to a functionality of the main library and can be
224+
/// accessed through a different route.
225+
///
226+
/// # Examples
227+
///
228+
/// ```
229+
/// use rust_code_analysis_web::server::run;
230+
///
231+
/// let host = "127.0.0.1";
232+
/// let port = 8080;
233+
/// let num_threads = 4;
234+
///
235+
/// // Runs a server on a determined host with a specific port and using certain
236+
/// // number of threads.
237+
/// // If the server runs correctly, it will be immediately interrupted,
238+
/// // otherwise an error will be shown.
239+
/// match run(&host, port, num_threads).await {
240+
/// Ok(_) => std::process::exit(0),
241+
/// Err(e) => eprintln!(
242+
/// "Cannot run the server at {}:{}: {}",
243+
/// host, port, e
244+
/// ),
245+
/// }
246+
/// ```
221247
pub async fn run(host: &str, port: u16, n_threads: usize) -> std::io::Result<()> {
222248
let max_size = 1024 * 1024 * 4;
223249

0 commit comments

Comments
 (0)