aboutsummaryrefslogtreecommitdiff
path: root/.config/awesome/quarrel/native/src/http.rs
blob: e995556302d7f7beb6dfead8044336e454f42e5f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
use ureq::{Agent, agent};
use std::{sync::LazyLock, thread};
use mlua::prelude::*;

static AGENT: LazyLock<Agent> = LazyLock::new(|| agent());

struct Stream(ureq::Body);

pub fn get(_: &Lua, url: String, callback: LuaFunction, err_callback: LuaFunction) -> LuaResult<()> {
    thread::spawn(|| {
        match AGENT.get(url).call() {
            Ok(body) => {

            },
            Err(err) => {
                err_callback.call(err.to_string());
            }
        }
        // callback.call::<>()
    });
    Ok(())
}