简体中文 | English
mxui-go-client is MXUI Golang client, which can use MXUI The platform quickly uses the API to generate UI components such as forms, tables, charts, file upload and download, audio and video playback and so on
go get -u github.com/liyiligang/mxui-go-client
//initialization
client, err := mxui.InitMXUIClient(mxui.ClientConfig{
Addr:"x.x.x.x:302",
PublicKeyPath:"./cert/ca_cert.pem",
CertName: "x.test.example.com",
NodeName: "MyNode",
ConnectTimeOut: time.Second * 5,
RequestTimeOut: time.Second * 5,
KeepaliveTime: time.Second * 1,
NotifyCall: func (nodeNotify mxui.NodeNotify){
fmt.Println("receive node notify: ", nodeNotify.Message)
},
})
if err != nil {
panic(err)
}
//Define API
type resume struct {
Name string
Age int
Boy bool
Occupation string `schema:"enum=teacher;sales;doctor"`
}
callFunc := func (form *resume) string {
sex := "boy"
if !form.Boy {
sex = "girl"
}
return "Hello World, My Name is " + form.Name+ ", " +
strconv.Itoa(form.Age)+ " years old, "+ sex + ". I'm a " +
form.Occupation + "."
}
//Create API visual UI
err := client.RegisterNodeFunc(mxui.NodeFuncRegister{
Name: "Hello World",
CallFunc: callFunc,
})
if err != nil {
fmt.Println(err)
}
- Any use questions or suggestions can be submitted to GitHub issue or contact me through QQ group
- Before submitting the issue, please search whether the relevant content has been proposed