more shit.
This commit is contained in:
1 parent
ba7763cbb1
commit
e7cec774d8
4 files changed
+112
-28
No files matched your search
Generated
+76
-17
@@ -645,6 +645,7 @@ dependencies = [
|
|||||||
"clap",
|
"clap",
|
||||||
"clap-verbosity-flag",
|
"clap-verbosity-flag",
|
||||||
"fraction",
|
"fraction",
|
||||||
|
"futures",
|
||||||
"hex",
|
"hex",
|
||||||
"home",
|
"home",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
@@ -739,32 +740,90 @@ dependencies = [
|
|||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "futures"
|
||||||
|
version = "0.3.26"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "13e2792b0ff0340399d58445b88fd9770e3489eff258a4cbc1523418f12abf84"
|
||||||
|
dependencies = [
|
||||||
|
"futures-channel",
|
||||||
|
"futures-core",
|
||||||
|
"futures-executor",
|
||||||
|
"futures-io",
|
||||||
|
"futures-sink",
|
||||||
|
"futures-task",
|
||||||
|
"futures-util",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "futures-channel"
|
||||||
|
version = "0.3.26"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2e5317663a9089767a1ec00a487df42e0ca174b61b4483213ac24448e4664df5"
|
||||||
|
dependencies = [
|
||||||
|
"futures-core",
|
||||||
|
"futures-sink",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "futures-core"
|
name = "futures-core"
|
||||||
version = "0.3.25"
|
version = "0.3.26"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "04909a7a7e4633ae6c4a9ab280aeb86da1236243a77b694a49eacd659a4bd3ac"
|
checksum = "ec90ff4d0fe1f57d600049061dc6bb68ed03c7d2fbd697274c41805dcb3f8608"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "futures-sink"
|
name = "futures-executor"
|
||||||
version = "0.3.25"
|
version = "0.3.26"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "39c15cf1a4aa79df40f1bb462fb39676d0ad9e366c2a33b590d7c66f4f81fcf9"
|
checksum = "e8de0a35a6ab97ec8869e32a2473f4b1324459e14c29275d14b10cb1fd19b50e"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "futures-task"
|
|
||||||
version = "0.3.25"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "2ffb393ac5d9a6eaa9d3fdf37ae2776656b706e200c8e16b1bdb227f5198e6ea"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "futures-util"
|
|
||||||
version = "0.3.25"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "197676987abd2f9cadff84926f410af1c183608d36641465df73ae8211dc65d6"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"futures-core",
|
"futures-core",
|
||||||
"futures-task",
|
"futures-task",
|
||||||
|
"futures-util",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "futures-io"
|
||||||
|
version = "0.3.26"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bfb8371b6fb2aeb2d280374607aeabfc99d95c72edfe51692e42d3d7f0d08531"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "futures-macro"
|
||||||
|
version = "0.3.26"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "95a73af87da33b5acf53acfebdc339fe592ecf5357ac7c0a7734ab9d8c876a70"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "futures-sink"
|
||||||
|
version = "0.3.26"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f310820bb3e8cfd46c80db4d7fb8353e15dfff853a127158425f31e0be6c8364"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "futures-task"
|
||||||
|
version = "0.3.26"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "dcf79a1bf610b10f42aea489289c5a2c478a786509693b80cd39c44ccd936366"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "futures-util"
|
||||||
|
version = "0.3.26"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9c1d6de3acfef38d2be4b1f543f553131788603495be83da675e180c8d6b7bd1"
|
||||||
|
dependencies = [
|
||||||
|
"futures-channel",
|
||||||
|
"futures-core",
|
||||||
|
"futures-io",
|
||||||
|
"futures-macro",
|
||||||
|
"futures-sink",
|
||||||
|
"futures-task",
|
||||||
|
"memchr",
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
"pin-utils",
|
"pin-utils",
|
||||||
"slab",
|
"slab",
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ minijinja = { version = "0.30.2", features = ["source"] }
|
|||||||
actix-utils = "3.0.1"
|
actix-utils = "3.0.1"
|
||||||
actix-web-lab = "0.18.9"
|
actix-web-lab = "0.18.9"
|
||||||
minijinja-autoreload = "0.30.2"
|
minijinja-autoreload = "0.30.2"
|
||||||
|
futures = "0.3.26"
|
||||||
|
|
||||||
[dependencies.apache-avro]
|
[dependencies.apache-avro]
|
||||||
version = "0.14.0"
|
version = "0.14.0"
|
||||||
|
|||||||
+26
-4
@@ -1,3 +1,5 @@
|
|||||||
|
#![feature(future_join)]
|
||||||
|
|
||||||
mod views;
|
mod views;
|
||||||
mod config;
|
mod config;
|
||||||
|
|
||||||
@@ -7,6 +9,10 @@ use minijinja_autoreload::AutoReloader;
|
|||||||
use std::io::{Error, ErrorKind};
|
use std::io::{Error, ErrorKind};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::{collections::HashMap, env, fs, io, path::PathBuf};
|
use std::{collections::HashMap, env, fs, io, path::PathBuf};
|
||||||
|
use tokio::time::{sleep, Duration};
|
||||||
|
use futures::{pin_mut, select, FutureExt};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
use actix_web::{
|
use actix_web::{
|
||||||
dev::ServiceResponse,
|
dev::ServiceResponse,
|
||||||
@@ -55,6 +61,15 @@ impl FromRequest for MiniJinjaRenderer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn print_shit() -> std::io::Result<()>{
|
||||||
|
let mut i = 0;
|
||||||
|
loop {
|
||||||
|
sleep(Duration::from_millis(1000)).await;
|
||||||
|
println!("he he! {:?}", i);
|
||||||
|
i +=1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
pub async fn web_ui_main(port: u16, enable_template_autoreload: bool) -> std::io::Result<()> {
|
pub async fn web_ui_main(port: u16, enable_template_autoreload: bool) -> std::io::Result<()> {
|
||||||
// The closure is invoked every time the environment is outdated to recreate it.
|
// The closure is invoked every time the environment is outdated to recreate it.
|
||||||
@@ -74,7 +89,7 @@ pub async fn web_ui_main(port: u16, enable_template_autoreload: bool) -> std::io
|
|||||||
|
|
||||||
let tmpl_reloader = web::Data::new(tmpl_reloader);
|
let tmpl_reloader = web::Data::new(tmpl_reloader);
|
||||||
|
|
||||||
HttpServer::new(move || {
|
let server = HttpServer::new(move || {
|
||||||
App::new()
|
App::new()
|
||||||
.app_data(tmpl_reloader.clone())
|
.app_data(tmpl_reloader.clone())
|
||||||
.service(views::index)
|
.service(views::index)
|
||||||
@@ -86,9 +101,16 @@ pub async fn web_ui_main(port: u16, enable_template_autoreload: bool) -> std::io
|
|||||||
.wrap(Logger::default())
|
.wrap(Logger::default())
|
||||||
})
|
})
|
||||||
.workers(2)
|
.workers(2)
|
||||||
.bind(("0.0.0.0", port))?
|
.bind(("0.0.0.0", port))?;
|
||||||
.run()
|
|
||||||
.await
|
let t1 = server.run().fuse();
|
||||||
|
let t2 = print_shit().fuse();
|
||||||
|
pin_mut!(t1, t2);
|
||||||
|
|
||||||
|
select!{
|
||||||
|
x = t1 => x,
|
||||||
|
y = t2 => y,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Error handler for a 404 Page not found error.
|
/// Error handler for a 404 Page not found error.
|
||||||
|
|||||||
+9
-7
@@ -3,6 +3,7 @@ use actix_web::http::header::q;
|
|||||||
use clap::builder::TypedValueParser;
|
use clap::builder::TypedValueParser;
|
||||||
use minijinja::context;
|
use minijinja::context;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use crate::webui::MiniJinjaRenderer;
|
use crate::webui::MiniJinjaRenderer;
|
||||||
@@ -10,7 +11,6 @@ use crate::webui::MiniJinjaRenderer;
|
|||||||
#[actix_web::get("/")]
|
#[actix_web::get("/")]
|
||||||
pub async fn index(
|
pub async fn index(
|
||||||
tmpl_env: MiniJinjaRenderer,
|
tmpl_env: MiniJinjaRenderer,
|
||||||
query: web::Query<HashMap<String, String>>,
|
|
||||||
) -> actix_web::Result<impl Responder> {
|
) -> actix_web::Result<impl Responder> {
|
||||||
tmpl_env.render("index.html", ())
|
tmpl_env.render("index.html", ())
|
||||||
}
|
}
|
||||||
@@ -18,7 +18,6 @@ pub async fn index(
|
|||||||
#[actix_web::get("/actions")]
|
#[actix_web::get("/actions")]
|
||||||
pub async fn actions(
|
pub async fn actions(
|
||||||
tmpl_env: MiniJinjaRenderer,
|
tmpl_env: MiniJinjaRenderer,
|
||||||
query: web::Query<HashMap<String, String>>,
|
|
||||||
) -> actix_web::Result<impl Responder> {
|
) -> actix_web::Result<impl Responder> {
|
||||||
tmpl_env.render("actions.html", ())
|
tmpl_env.render("actions.html", ())
|
||||||
}
|
}
|
||||||
@@ -26,7 +25,6 @@ pub async fn actions(
|
|||||||
#[actix_web::get("/overview")]
|
#[actix_web::get("/overview")]
|
||||||
pub async fn overview(
|
pub async fn overview(
|
||||||
tmpl_env: MiniJinjaRenderer,
|
tmpl_env: MiniJinjaRenderer,
|
||||||
query: web::Query<HashMap<String, String>>,
|
|
||||||
) -> actix_web::Result<impl Responder> {
|
) -> actix_web::Result<impl Responder> {
|
||||||
tmpl_env.render("overview.html", ())
|
tmpl_env.render("overview.html", ())
|
||||||
}
|
}
|
||||||
@@ -35,7 +33,7 @@ pub async fn overview(
|
|||||||
pub async fn overview_submit_button(
|
pub async fn overview_submit_button(
|
||||||
req: HttpRequest,
|
req: HttpRequest,
|
||||||
tmpl_env: MiniJinjaRenderer,
|
tmpl_env: MiniJinjaRenderer,
|
||||||
query: web::Query<HashMap<String, String>>
|
query: web::Query<HashMap<String, String>>,
|
||||||
) -> actix_web::Result<impl Responder> {
|
) -> actix_web::Result<impl Responder> {
|
||||||
let ctx = context! {
|
let ctx = context! {
|
||||||
event_type => query.get("event_type").unwrap_or(&"".to_string()),
|
event_type => query.get("event_type").unwrap_or(&"".to_string()),
|
||||||
@@ -43,15 +41,19 @@ pub async fn overview_submit_button(
|
|||||||
tmpl_env.render("partials/overview/submit_button.html", ctx)
|
tmpl_env.render("partials/overview/submit_button.html", ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize, Debug)]
|
||||||
|
struct CreateEventPayload {
|
||||||
|
event: String,
|
||||||
|
event_type: String,
|
||||||
|
}
|
||||||
|
|
||||||
#[actix_web::post("/v1/events/{event_type}")]
|
#[actix_web::post("/v1/events/{event_type}")]
|
||||||
pub async fn push_event(
|
pub async fn push_event(
|
||||||
req: HttpRequest,
|
req: HttpRequest,
|
||||||
tmpl_env: MiniJinjaRenderer,
|
tmpl_env: MiniJinjaRenderer,
|
||||||
query: web::Query<HashMap<String, String>>,
|
web::Form(form): web::Form<CreateEventPayload>,
|
||||||
) -> actix_web::Result<impl Responder> {
|
) -> actix_web::Result<impl Responder> {
|
||||||
println!(">> {:?}", req);
|
|
||||||
let shit = req.match_info().get("event_type").unwrap();
|
let shit = req.match_info().get("event_type").unwrap();
|
||||||
let event = req.match_info().get("event").unwrap();
|
|
||||||
let ctx = context! {
|
let ctx = context! {
|
||||||
event_type => shit,
|
event_type => shit,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in new issue
Block a user