Skip to content

Latest commit

 

History

History
94 lines (78 loc) · 2.47 KB

README-en.md

File metadata and controls

94 lines (78 loc) · 2.47 KB

简体中文 | English

About

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

Document

Preview

Install

go get -u github.com/liyiligang/mxui-go-client

Basic Usage

//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)
}

Generated UI

Request parameters

Return value

Contact information

QQ Group: 757595139

Questions or suggestions

  • 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

License

Apache-2.0