Skip to content

Commit

Permalink
Merge pull request #11 from ArtisanCloud/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Matrix-X authored Feb 10, 2025
2 parents d7c7729 + 438e1af commit 6093525
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 16 deletions.
4 changes: 2 additions & 2 deletions internal/kernel/accessToken.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@ func (acHandler *AccessTokenHandler) OverrideGetMiddlewareOfLog() {
return func(request *http.Request) (response *http.Response, err error) {
l = l.WithContext(request.Context())

request2.LogRequest(l, request)
request2.LogRequest(acHandler.Config.HttpDebug, l, request)
response, err = handle(request)
if err == nil {
l.WithContext(request.Context())
response2.LogResponse(l, response)
response2.LogResponse(acHandler.Config.HttpDebug, l, response)
}
return response, err
}
Expand Down
4 changes: 2 additions & 2 deletions internal/kernel/baseClient.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@ func (client *BaseClient) OverrideGetMiddlewareOfLog() {
return func(request *http.Request) (response *http.Response, err error) {
l = l.WithContext(request.Context())

request2.LogRequest(l, request)
request2.LogRequest(client.Config.HttpDebug, l, request)
response, err = handle(request)
if err == nil {
l.WithContext(request.Context())
response2.LogResponse(l, response)
response2.LogResponse(client.Config.HttpDebug, l, response)
}
return response, err
}
Expand Down
5 changes: 4 additions & 1 deletion internal/kernel/request/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import (
"net/http"
)

func LogRequest(logger *logger.Logger, request *http.Request) {
func LogRequest(needLog bool, logger *logger.Logger, request *http.Request) {
if !needLog {
return
}
var output bytes.Buffer
// 前置中间件
output.WriteString(fmt.Sprintf("%s %s ", request.Method, request.URL.String()))
Expand Down
5 changes: 4 additions & 1 deletion internal/kernel/response/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import (
"net/http/httputil"
)

func LogResponse(l *logger.Logger, response *http.Response) {
func LogResponse(needLog bool, l *logger.Logger, response *http.Response) {
if !needLog {
return
}
var output bytes.Buffer
output.Write([]byte("------------------"))
output.Write([]byte("response content:"))
Expand Down
2 changes: 1 addition & 1 deletion internal/kernel/response/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func ParseResponseToObject(res *http.Response, obj interface{}) error {
}

// 打印响应内容 (可选)
fmt.Printf("Response Body: %s\n", string(bodyBytes))
//fmt.Printf("Response Body: %s\n", string(bodyBytes))

// 将响应体内容解析到目标对象
err = json.Unmarshal(bodyBytes, obj)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type PublishGetRes struct {

PublishId uint64 `json:"publish_id"`
PublishStatus int `json:"publish_status"`
ArticleId interface{} `json:"article_id"`
ArticleId string `json:"article_id"`
ArticleDetail *ArticleDetail `json:"article_detail"`
FailIdx []int `json:"fail_idx"`
}
Expand Down
16 changes: 8 additions & 8 deletions pkg/client/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ type MediaXConfig struct {
}

type LocalConfig struct {
*WeChatOfficialAccountConfig `yaml:"wechat_config" json:"weChatConfig"`
*DouYinConfig `yaml:"douyin_config" json:"douYinConfig"`
*RedBookConfig `yaml:"redbook_config" json:"redBookConfig"`
*WeChatOfficialAccountConfig `yaml:"wechat_config" json:"wechat_config"`
*DouYinConfig `yaml:"douyin_config" json:"douyin_config"`
*RedBookConfig `yaml:"redbook_config" json:"redbook_config"`
}

type AppConfig struct {
BaseUri string `yaml:"base_uri" json:"baseUri"`
ProxyUri string `yaml:"proxy_uri" json:"proxyUri"`
BaseUri string `yaml:"base_uri" json:"base_uri"`
ProxyUri string `yaml:"proxy_uri" json:"proxy_uri"`
Timeout float64 `yaml:"timeout" json:"timeout"`
AppID string `yaml:"app_id" json:"appId"`
AppSecret string `yaml:"app_secret" json:"appSecret"`
HttpDebug bool `yaml:"http_debug" json:"httpDebug"`
AppID string `yaml:"app_id" json:"app_id"`
AppSecret string `yaml:"app_secret" json:"app_secret"`
HttpDebug bool `yaml:"http_debug" json:"http_debug"`
}

0 comments on commit 6093525

Please sign in to comment.