This PR removes the distinction between GET/POST requests to the telegram API, in favour of just using POST requests.
This allows us to avoid URL length limits which can occur on GET requests when sending large amounts of data, as well as reducing the amount of code that needs maintenance.
As a side effect, since we now only send POST requests, we can no longer rely on the "GetTimeout" and "PostTimeout" fields for defining different timeouts.
So to fix this, we now also need to allow for passing individual timeouts to each method. This would allow us to set a global timeout on the bot to a low-ish value, and higher individual timeouts on larger requests (eg sending files).
To do this, I added a RequestOpts struct to each method's optional values, allowing users to pass extra settings. Currently, these settings are a Timeout field to control timeouts, and an APIURL field to define which bot API instance this request should be made to. More can be added in the future.
Impact
Are your changes backwards compatible?
No - this update includes breaking changes which will break compilation.
The fixes are relatively straightforward though, and most users will be able to fix this by ammending their call to NewBot() to use the new format. Sample bot has been updated to show how this is done.
Additionally, some methods which previously didnt have optionals now take an optional to allow for request passing. These can be fixed by just adding an extra nil arg at the end of the call - theyll use the global bot default instead.
Highest risk is likely to be the timeouts for files - these should be updated on a per-case basis.
Have you included documentation, or updated existing documentation? Yes
Do errors and log messages provide enough context? N/A
What
This PR removes the distinction between GET/POST requests to the telegram API, in favour of just using POST requests. This allows us to avoid URL length limits which can occur on GET requests when sending large amounts of data, as well as reducing the amount of code that needs maintenance.
Issue with POST requests was raised here.
As a side effect, since we now only send POST requests, we can no longer rely on the "GetTimeout" and "PostTimeout" fields for defining different timeouts. So to fix this, we now also need to allow for passing individual timeouts to each method. This would allow us to set a global timeout on the bot to a low-ish value, and higher individual timeouts on larger requests (eg sending files).
To do this, I added a
RequestOpts
struct to each method's optional values, allowing users to pass extra settings. Currently, these settings are aTimeout
field to control timeouts, and anAPIURL
field to define which bot API instance this request should be made to. More can be added in the future.Impact
NewBot()
to use the new format. Sample bot has been updated to show how this is done. Additionally, some methods which previously didnt have optionals now take an optional to allow for request passing. These can be fixed by just adding an extranil
arg at the end of the call - theyll use the global bot default instead.Highest risk is likely to be the timeouts for files - these should be updated on a per-case basis.