DEVELOPMENT ENVIRONMENT

~liljamo/deck-builder

f9461f049a1ea59c8bc51d9b387e8a60b07269ca — Jonni Liljamo 1 year, 8 months ago 4056e5a
feat(client): add macros for http requests
2 files changed, 43 insertions(+), 0 deletions(-)

M client/src/macros/mod.rs
A client/src/macros/request.rs
M client/src/macros/mod.rs => client/src/macros/mod.rs +2 -0
@@ 8,6 8,8 @@

mod async_task;

mod request;

/*
use crate::{async_task_start_call, async_task_handle_call};


A client/src/macros/request.rs => client/src/macros/request.rs +41 -0
@@ 0,0 1,41 @@
/*
 * This file is part of laurelin_client
 * Copyright (C) 2023 Jonni Liljamo <jonni@liljamo.com>
 *
 * Licensed under GPL-3.0-only.
 * See LICENSE for licensing information.
 */

#[macro_export]
macro_rules! get_request_auth {
    ($no:expr, $path:expr) => {
        $no.req
            .get(&format!("{}{}", &$no.api_address, &$path))
            .header("Authorization", &$no.user_token)
            .send()
            .unwrap()
    };
}

#[macro_export]
macro_rules! post_request {
    ($no:expr, $path:expr, $input:expr) => {
        $no.req
            .get(&format!("{}{}", &$no.api_address, &$path))
            .json($input)
            .send()
            .unwrap()
    };
}

#[macro_export]
macro_rules! post_request_auth {
    ($no:expr, $path:expr, $input:expr) => {
        $no.req
            .get(&format!("{}{}", &$no.api_address, &$path))
            .header("Authorization", &$no.user_token)
            .json($input)
            .send()
            .unwrap()
    };
}