diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f670ebb200762eb91e81fb081fe526f98f21423..6cae5838bdaee1ca70922d46d02acd55f5462235 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ All notable changes to this project are documented below. The format is based on [keep a changelog](http://keepachangelog.com) and this project uses [semantic versioning](http://semver.org). ## [Unreleased] +### Added +- New timeout option to HTTP request function in the code runtime. + ## [2.0.0] - 2018-05-14 diff --git a/server/runtime_nakama_module.go b/server/runtime_nakama_module.go index 8b94143cd3ab7ee6632ae33cdce5aa99865b60ae..b7849a3f72b431a30a9132b453315b8505fa9302 100644 --- a/server/runtime_nakama_module.go +++ b/server/runtime_nakama_module.go @@ -532,6 +532,10 @@ func (n *NakamaModule) httpRequest(l *lua.LState) int { return 0 } + // Set a custom timeout if one is provided, or use the default. + timeoutMs := l.OptInt64(5, 5000) + n.client.Timeout = time.Duration(timeoutMs) * time.Millisecond + // Prepare request body, if any. var requestBody io.Reader if body != "" {