Closed 2547techno closed 3 months ago
This is a mistake with the meta comments in src/controllers/plugins/api/HTTPRequest.hpp
.
This comment should be deleted:
/**
* @lua@class HTTPResponse
* @lua@field data string Data received from the server
* @lua@field status integer? HTTP Status code returned by the server
* @lua@field error string A somewhat human readable description of an error if such happened
*/
The order of includes in src/controllers/plugins/LuaAPI.hpp
should probably be switched from:
/**
* @includefile common/Channel.hpp
* @includefile controllers/plugins/api/ChannelRef.hpp
* @includefile controllers/plugins/api/HTTPRequest.hpp
* @includefile controllers/plugins/api/HTTPResponse.hpp
* @includefile common/network/NetworkCommon.hpp
*/
to:
/**
* @includefile common/Channel.hpp
* @includefile controllers/plugins/api/ChannelRef.hpp
* @includefile controllers/plugins/api/HTTPResponse.hpp
* @includefile controllers/plugins/api/HTTPRequest.hpp
* @includefile common/network/NetworkCommon.hpp
*/
Swapping HTTPRequest and HTTPResponse. Then the luals meta file should be regenerated.
BTW instead of res.status(res)
you can use res:status()
.
Checklist
Describe your issue
HTTP api type definition in the generated
plugin-meta.lua
file definesHTTPResponse.status
as an integer. However, when used in a plugin it is a function that (almost) follows the docs:"Almost", because it says the
data()
function take no parameters, but after using it I realized it needs anHTTPResponse
type table is required as the parameter. The following code is what works for me currently:When calling the
status
function with an incorrect/without a parameter, the following errors are returned:I figured there was a mistake somewhere, but I'm not sure which definition would be correct. Could the docs be fixed to reflect this?
Screenshots
No response
OS and Chatterino Version
Chatterino Nightly 2.5.1 (commit 7bfb5ac0) built on 2024-06-23 with Qt 6.7.1, MSVC 194033811 Running on Windows 10 Version 22H2, kernel: 10.0.19045