Browse Source

修改获取站点信息方法

master v0.6.2
guzeng 2 years ago
parent
commit
961bae3566
2 changed files with 33 additions and 16 deletions
  1. +20
    -16
      client.siteinfo.go
  2. +13
    -0
      client.siteinfo_test.go

+ 20
- 16
client.siteinfo.go View File

@ -1,15 +1,15 @@
package siterpc
// import (
// "encoding/json"
// "errors"
// "strconv"
// "time"
import (
"encoding/json"
"log"
"strconv"
"time"
// "git.tetele.net/tgo/crypter"
"git.tetele.net/tgo/crypter"
// "github.com/golang/protobuf/proto"
// )
"github.com/golang/protobuf/proto"
)
type SiteInfoReq struct {
Master string
@ -17,9 +17,9 @@ type SiteInfoReq struct {
}
type SiteInfoRes struct {
SiteId string
Dbname string
Domainname string
SiteId string `json:"site_id"`
Dbname string `json:"database"`
Domainname string `json:"domainname"`
}
/**
@ -27,8 +27,8 @@ type SiteInfoRes struct {
* 请求及回均加密验签
* 2021/06/24
* GZ
func GetSiteInfoByHost(host string, url ...string) (*SiteInfoRes, error) {
*/
func GetSiteInfoByHost(master, host string, url ...string) (*SiteInfoRes, error) {
conn, err := rpc_server_conn(url...)
if err != nil {
@ -36,7 +36,7 @@ func GetSiteInfoByHost(host string, url ...string) (*SiteInfoRes, error) {
}
defer conn.Close()
arg := SiteInfoReq{host}
arg := SiteInfoReq{master, host}
data_json, err := json.Marshal(arg)
if err != nil {
@ -60,8 +60,13 @@ func GetSiteInfoByHost(host string, url ...string) (*SiteInfoRes, error) {
return nil, err
}
res_data := GetOrgData(res)
res_data, err := GetOrgData(res)
log.Println(res_data, err)
if err != nil {
return nil, err
}
var res_arr SiteInfoRes
err = json.Unmarshal([]byte(res_data), &res_arr)
@ -71,4 +76,3 @@ func GetSiteInfoByHost(host string, url ...string) (*SiteInfoRes, error) {
}
return &res_arr, nil
}
*/

+ 13
- 0
client.siteinfo_test.go View File

@ -0,0 +1,13 @@
package siterpc
import (
"testing"
)
func Test_GetSiteInfoByHost(t *testing.T) {
res, err := GetSiteInfoByHost("http://devmaster.tetele.net", "dev.tetele.net")
t.Log(res)
t.Log(err)
}

Loading…
Cancel
Save