mirror of
https://git.madhouse-project.org/algernon/iocaine.git
synced 2025-02-24 02:18:47 +01:00
No need for a Mutex
There's no need for a `Mutex` in `StatefulIocaine`, so drop it - keep only `Arc`. Signed-off-by: Gergely Nagy <me@gergo.csillger.hu>
This commit is contained in:
parent
a0410a528d
commit
0b76a1633e
1 changed files with 4 additions and 8 deletions
12
src/app.rs
12
src/app.rs
|
@ -10,14 +10,14 @@ use axum::{
|
||||||
routing::get,
|
routing::get,
|
||||||
Router,
|
Router,
|
||||||
};
|
};
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::Arc;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
assembled_statistical_sequences::AssembledStatisticalSequences, config::Config,
|
assembled_statistical_sequences::AssembledStatisticalSequences, config::Config,
|
||||||
garglebargle::GargleBargle, wurstsalat_generator_pro::WurstsalatGeneratorPro,
|
garglebargle::GargleBargle, wurstsalat_generator_pro::WurstsalatGeneratorPro,
|
||||||
};
|
};
|
||||||
|
|
||||||
type StatefulIocaine = Arc<Mutex<Iocaine>>;
|
type StatefulIocaine = Arc<Iocaine>;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Iocaine {
|
pub struct Iocaine {
|
||||||
|
@ -46,7 +46,7 @@ impl Iocaine {
|
||||||
|
|
||||||
pub async fn run(self) -> std::result::Result<(), std::io::Error> {
|
pub async fn run(self) -> std::result::Result<(), std::io::Error> {
|
||||||
let bind = &self.config.server.bind.clone();
|
let bind = &self.config.server.bind.clone();
|
||||||
let state: StatefulIocaine = Arc::new(Mutex::new(self));
|
let state: StatefulIocaine = Arc::new(self);
|
||||||
let app = Router::new()
|
let app = Router::new()
|
||||||
.route("/", get(poison_root))
|
.route("/", get(poison_root))
|
||||||
.route("/{*path}", get(poison_path))
|
.route("/{*path}", get(poison_path))
|
||||||
|
@ -87,11 +87,7 @@ fn poison(iocaine: &StatefulIocaine, headers: axum::http::HeaderMap, path: &str)
|
||||||
.to_str()
|
.to_str()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
Html(AssembledStatisticalSequences::generate(
|
Html(AssembledStatisticalSequences::generate(iocaine, host, path))
|
||||||
&iocaine.lock().unwrap(),
|
|
||||||
host,
|
|
||||||
path,
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn poison_root(
|
async fn poison_root(
|
||||||
|
|
Loading…
Reference in a new issue