Game servers can make web requests to external API's using the built-in HttpManager. Each request is signed and can be validated by the service you are calling, see Verifying GameServer HTTP Requests below.
Overview
// Web Requests can only be made on the gameservers. Requests made on the client will fail.
if (!Game.IsServer()) return;
let getResult = HttpManager.GetAsync("https://jsonplaceholder.typicode.com/todos/1");
print(getResult.statusCode, getResult.data);
let postResult = HttpManager.PostAsync("https://jsonplaceholder.typicode.com/posts", json.encode({
title: 'foo',
body: 'bar',
}));
print(postResult.statusCode, postResult.data);
Requests originating from a GameServer will include an additional header called: x-airship-signature containing a JWT with request details including:
{
"jti": string, // JWT ID - UUID e.x. 8e2b6b98-14ba-4724-b95b-3627b6d48d5b
"iat": number, // u64 - Timestamp this jwt was issued, in seconds since Unix Epoch
"exp": number, // u64 - Timestamp this jwt expires, in seconds since Unix Epoch
"hostname": string, // e.x. "mywebsite.test" Will include port if not https, http 443, 80
"path": string, // e.x. "/path/123" excludes query params
"method": string, // GET, POST, etc.
"gameId": string, // This should match your gameId on create.airship.gg
"serverId": string,
"sceneId": string, // The default starting scene of the server (doesn't update if changed)
"region": string,
"organizationId": string,
"type": "game-server"
}
Each JWT is signed with a specific public key that can be identified in the header using kid: