Southclaws/pawn-requests

Refactor the library and make it easier to use

srafay opened this issue · 4 comments

Hello, it seems like like this library was inspired by the python's request library. But there are many things which could be improved in this library so that it's more easier to use (and it has a lot of potential and possibly can be the standard for making HTTP requests in the near future)

What I want to suggest is to send requests like this ( a blocking call )

response = requests.post(url, body, headers);
OR
response = requests.get(url, headers);

if (response.status_code == HTTP_STATUS_OK):
    data = response.data;
    * do some operations *

Or if you want to have a callback associated with it ( non blocking call )

requests.post(url, body, headers, callback=callback_func, callback_params=params);
public callback_func(response, params){
if (response.status_code == 200)
    * do some operations *
}

Is it possible? I am also interested in contributing if you want. Thanks!

What are the use-cases for a blocking call?

Also, regarding contributions, the current C++ codebase is locked and I am rewriting it in Rust on another branch.

What are the use-cases for a blocking call?

@Southclaws Well you don't have to worry about callbacks, it's very simple!

But when would you ever want to perform a blocking call that could potentially freeze the entire gamemode (remember, SA:MP is single threaded so if the AMX stops then all sync stops too) for what might be a 3 second request.

I can add it in a future version for performing requests on startup but it's not something I see a huge priority for right now as it won't add any new functionality.

Yeah not a good idea to use it. A non-blocking request with a callback func and params should be just fine!