1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
use crateListenOn;
use crateSessionManager;
use ;
use Arc;
use info;
use crateconfigure_routes;
use crate;
/// Starts an HTTP server with the given configuration.
///
/// # Arguments
///
/// * `session_manager` - A shared reference to the `SessionManager`, used to manage user sessions.
/// * `metrics_collector` - A shared reference to the `MetricsCollector`, used for collecting server metrics.
/// * `listen_on` - The address or hostname where the server will listen, typically an IP address or hostname.
/// * `port` - The port number on which the server will accept requests.
///
/// # Returns
///
/// Returns a `std::io::Result<()>` that resolves when the server stops running or if an
/// error occurs when binding or running the HTTP server.
///
/// # Details
///
/// This function initializes and starts an Actix Web server:
/// - The server is configured with a custom `MetricsMiddleware` for metrics collection.
/// - Routes are dynamically configured using the `configure_routes` function, which is provided with
/// references to the `SessionManager` and `MetricsCollector`.
/// - The server binds to the provided `listen_on` address and `port`, constructing the bind address
/// in the format `"address:port"`.
///
/// The server starts asynchronously and will remain active, awaiting requests, until it is stopped
/// or encounters an error.
///
/// # Errors
///
/// This function will return an `Err` result if:
/// - The server fails to bind to the specified address and port.
/// - An error occurs while attempting to run the server.
pub async