Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added AngelScript HTTP request API #107

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ohlidalp
Copy link
Member

@ohlidalp ohlidalp commented Oct 5, 2020

Excerpt from new file "contrib/example-script.as":

void main() {
    server.Log("Hello angelscript!");
    
    HttpResponse response = server.httpRequest(
        "GET",                    // Method: GET/POST/PUT/DELETE
        "www.example.com",        // Host
        "/",                      // Server file path
        "text/plain",             // Content type, see https://en.wikipedia.org/wiki/Media_type
        "");                      // Payload
    string logHttp = "HTTP response code: " + response.getCode(); // For text, use `response.getBody()`
    server.Log(logHttp);
}

Outputs:

05-10-2020 14:35:51|t01| INFO|SCRIPT|Hello angelscript!
05-10-2020 14:35:52|t01| INFO|SCRIPT|HTTP response code: 200

Renamed ScriptEngine to script-engine, for consistency.
Extracted 'server-script' from 'script-engine', moved class ServerScript
added function `static void ServerScript::Register()`, code extracted from `ScriptEngine::Init()`
See file 'contrib/example-script.as'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant