81 lines
2.0 KiB
Go
81 lines
2.0 KiB
Go
// Package client ...
|
|
//
|
|
// Description : client ...
|
|
//
|
|
// Author : go_developer@163.com<白茶清欢>
|
|
//
|
|
// Date : 2021-11-30 10:52 上午
|
|
package client
|
|
|
|
import "net/http"
|
|
|
|
// Config 配置
|
|
//
|
|
// Author : go_developer@163.com<白茶清欢>
|
|
//
|
|
// Date : 10:54 上午 2021/11/30
|
|
type Config struct {
|
|
Domain string `json:"domain" yaml:"domain"` // 配置中心域名
|
|
Namespace string `json:"namespace" yaml:"namespace"` // 命名空间
|
|
AppID string `json:"app_id" yaml:"app-id"` // 授权的APP_ID
|
|
LocalCacheEnable bool `json:"local_cache_enable" yaml:"local-cache-enable"` // 是否启用本地缓存
|
|
}
|
|
|
|
// RequestURIConfig 请求URI的配置
|
|
//
|
|
// Author : go_developer@163.com<白茶清欢>
|
|
//
|
|
// Date : 11:08 上午 2021/11/30
|
|
type RequestURIConfig struct {
|
|
URI string `json:"uri"`
|
|
Method string `json:"method"`
|
|
Timeout int `json:"timeout"`
|
|
}
|
|
|
|
var (
|
|
// SetConfigURI 设置配置
|
|
SetConfigURI = &RequestURIConfig{
|
|
URI: "/config/set",
|
|
Method: http.MethodPost,
|
|
Timeout: 100,
|
|
}
|
|
// GetConfigURI 读取配置
|
|
GetConfigURI = &RequestURIConfig{
|
|
URI: "/config/read",
|
|
Method: http.MethodGet,
|
|
Timeout: 100,
|
|
}
|
|
// UpdateConfigURI 更新配置
|
|
UpdateConfigURI = &RequestURIConfig{
|
|
URI: "/config/update",
|
|
Method: http.MethodPost,
|
|
Timeout: 100,
|
|
}
|
|
// DeleteConfigURI 删除配置
|
|
DeleteConfigURI = &RequestURIConfig{}
|
|
// CreateNamespaceURI 创建命名空间
|
|
CreateNamespaceURI = &RequestURIConfig{
|
|
URI: "/namespace/create",
|
|
Method: http.MethodPost,
|
|
Timeout: 100,
|
|
}
|
|
// ActiveNamespaceURI 激活命名空间
|
|
ActiveNamespaceURI = &RequestURIConfig{
|
|
URI: "/namespace/active",
|
|
Method: http.MethodPost,
|
|
Timeout: 100,
|
|
}
|
|
)
|
|
|
|
var (
|
|
// PostHeader 请求header
|
|
PostHeader = map[string]string{
|
|
"Content-Type": "application/json",
|
|
"X-Request-Flag": "center-config-client",
|
|
}
|
|
// GetHeader 请求header
|
|
GetHeader = map[string]string{
|
|
"X-Request-Flag": "center-config-client",
|
|
}
|
|
)
|