http/https
If you need to use network requests (http/https
) in GenUI
, you need to use the plugin gen_makepad_http
.
You can refer to this example: todo example
Ract
After the installation is complete, a .plugins
directory will appear in your GenUI project, which contains a gen_makepad_http/token.toml
file.
Please add the following dependencies to the project's Cargo.toml
:
main.rs
This HttpPublisher
is registered globally, the name is set to http1
, and the init
function is used for initialization
The following requests are currently supported:
http_get!
http_post!
http_put!
http_delete!
http_patch!
These macros are used in the same way:
http_get!($Id: tt)
http_get!($Id: tt, $Url: expr)
http_get!($Id: tt, $Url: expr, $Patch: expr)
$Id
: the function name corresponding to the response$Url
: the address attached to thebasic url
, for example,basic_url
islocalhost:8888/hello
, if this$Url
is set to"/user/get/1"
, then the completeurl
is:localhost:8888/hello/user/get/1
$Patch
:Into<PatchRequest>
, in short, you can directly use a serializable type orPatchRquest
The request publisher, where you can configure the basic request configuration (BasicConfig
)
default is:
Protocol::Http
Content-Type: application/json
If you need to add header,please use:pub fn push_header(&mut self, header: HttpRequestHeader, value: String) ;
Vec<u8>
implements data serialization, which means that you can use any data serialized by serde
as HttpRequestBody