A simple library, written in rust for sending GET/POST requests, included with an async file downloader. Intended for mostly small projects which need to make quick GET/POST requests or download files.

src/main.rs is for the manual tests I did while coding the src/lib.rs

This repository will be used in an even larger upcoming project of mine

Functions

sync_get

>

Test function which sends a synchronous get request to any api and returns a response object which can be then parsed into json

Recommended to use the requestsrs::requests::apireferencer::getandsave_json function instead of this.

getandsave_json

>

Sends a get request to an api ,parses the json response and returns the json object

Example 1

use requestsrs::requests::apireferencer::getandsave_json;

getandsave_json("https://api-url.com", true, false).expect("Some error message!")

Having save=true will parse the json value and save it to a json file.

Having silent_mode = false will pretty-print out the json response(Useful for debugging purposes?).

This function is asynchrounous so many get requests can be sent at a time.

printandpost_json

>

Sends a POST request to any api and returns the response json object

Example 1

use requestsrs::requests::apireferencer::printandpost_json;

printandpostjson("https://api-url.com", "path/to/jsonfile", true)

If silent_mode is set to true then the function will silently send a POST request and return the response json object

If set to false then the function will send a POST request and pretty print out the response json, alongside returning > it as a value as well

asyncdownloadfile

>

Downloads any file asynchronously

use requestsrs::requests::filedownloader::asyncdownloadfile;

asyncdownloadfile("https://download-the-file.exe", "yourdownloadpath").expect("Some error message")