sofie-http 0.2.0

The HTTP server, areas, routes and the handler model.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/// Tasks a server starts for itself, stopped when `serve` returns, however it returns: each
/// holds the database, and one forgotten would outlive the server for the life of the process.
#[derive(Default)]
pub(crate) struct Background(Vec<tokio::task::AbortHandle>);

impl Background {
    pub(crate) fn spawn(&mut self, task: impl Future<Output = ()> + Send + 'static) {
        self.0.push(tokio::spawn(task).abort_handle());
    }
}

impl Drop for Background {
    fn drop(&mut self) {
        for task in &self.0 {
            task.abort();
        }
    }
}