DEVELOPMENT ENVIRONMENT

~liljamo/wallhavenapirandom

752dc9365ccf1589698117f20fdb41989947aeb1 — Jonni Liljamo 1 year, 8 months ago ce74b23
feat: "logging" and a few deps
3 files changed, 21 insertions(+), 2 deletions(-)

M Cargo.lock
M Cargo.toml
M src/main.rs
M Cargo.lock => Cargo.lock +12 -0
@@ 827,6 827,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"

[[package]]
name = "openssl-src"
version = "111.24.0+1.1.1s"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3498f259dab01178c6228c6b00dcef0ed2a2d5e20d648c017861227773ea4abd"
dependencies = [
 "cc",
]

[[package]]
name = "openssl-sys"
version = "0.9.80"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 835,6 844,7 @@ dependencies = [
 "autocfg",
 "cc",
 "libc",
 "openssl-src",
 "pkg-config",
 "vcpkg",
]


@@ 1362,6 1372,8 @@ name = "wallhavenapirandom"
version = "0.1.0"
dependencies = [
 "actix-web",
 "log",
 "openssl",
 "rand",
 "reqwest",
 "serde",

M Cargo.toml => Cargo.toml +2 -0
@@ 11,3 11,5 @@ actix-web = "4.2.1"
reqwest = { version = "0.11.13", features = ["json"] }
serde = { version = "1.0.152", features = ["derive"] }
rand = "0.8.5"
openssl = { version = "0.10.45", features = ["vendored"] }
log = "0.4.17"

M src/main.rs => src/main.rs +7 -2
@@ 59,18 59,22 @@ async fn random(args: web::Path<RandomArgs>) -> impl Responder {
        "https://wallhaven.cc/api/v1/search?atleast={atl}&ratios={rats}&purity={pur}&categories={cats}&sorting=random&q={q}&apikey={api_key}"
    );

    log::info!("doing the thing with args 'atl={atl} rats={rats} pur={pur} cats={cats} q={q}'");

    let search_resp = reqwest::get(wh_url).await;

    match search_resp {
        Err(err) => {
            println!("search_resp: {}", err);
            log::error!(
                "oh nej! we hast failed! like, in the 'search_resp' thingy. err is '{err}'"
            );
        }
        Ok(search_resp) => {
            let json = search_resp.json::<WHSearchRes>().await;

            match json {
                Err(err) => {
                    println!("json: {}", err);
                    log::error!("rövhål! failed in the 'json' match. err is '{err}'");
                }
                Ok(res) => {
                    let imgs = res.data;


@@ 90,6 94,7 @@ async fn random(args: web::Path<RandomArgs>) -> impl Responder {

#[actix_web::main]
async fn main() -> std::io::Result<()> {
    log::info!("startedth uppeth");
    HttpServer::new(|| App::new().service(random))
        .bind(("127.0.0.1", 3000))?
        .run()