🐱👤 gmsv_reqwest
This module is a drop-in replacement for Garry's Mod's HTTP
function, inspired by gmsv_chttp
created by timschumi.
The module uses the reqwest
crate for dispatching HTTP requests, tokio
crate for async/thread scheduling runtime and the rustls
crate for SSL/TLS.
This module was written in Rust and serves as a decent example on how to write a Garry's Mod binary module in Rust. (Thank you Willox for the base!)
Installation
Download the relevant module for your server's operating system and platform/Gmod branch from the releases section.
Drop the module into garrysmod/lua/bin/
in your server's files. If the bin
folder doesn't exist, create it.
If you're not sure on what operating system/platform your server is running, run this in your server's console:
lua_run print((system.IsWindows()and"Windows"or system.IsLinux()and"Linux"or"Unsupported").." "..(jit.arch=="x64"and"x86-64"or"x86"))
Usage
To use reqwest in your addons, you can put this snippet at the top of your code, which will fallback to Gmod's default HTTP function if reqwest is not installed on the server.
if pcall(require, "reqwest") and reqwest ~= nil then
my_http = reqwest
else
my_http = HTTP
end