feat: 支持请求中独立的 Path 字段

Signed-off-by: Ke Jie <chzealot@gmail.com>
This commit is contained in:
Ke Jie 2024-06-11 20:12:14 +08:00
parent f92294fda9
commit 5f78647a9a
3 changed files with 9 additions and 1 deletions

View File

@ -41,7 +41,7 @@ type UserAgentConfig struct {
func NewDingtalkGoSDKUserAgent() *UserAgentConfig {
return &UserAgentConfig{
UserAgent: "dingtalk-sdk-go/v0.8.0",
UserAgent: "dingtalk-sdk-go/v0.9.0",
}
}

View File

@ -7,6 +7,7 @@ import (
type GraphRequestLine struct {
Method string `json:"method"`
Uri string `json:"uri"`
Path string `json:"-"`
}
type GraphRequest struct {
RequestLine GraphRequestLine `json:"requestLine"`

View File

@ -3,6 +3,7 @@ package plugin
import (
"context"
"encoding/json"
"strings"
"github.com/open-dingtalk/dingtalk-stream-sdk-go/payload"
)
@ -29,6 +30,12 @@ func (h *DefaultPluginFrameHandler) OnEventReceived(ctx context.Context, df *pay
if err != nil {
return nil, err
}
pos := strings.Index(msgData.RequestLine.Uri, "?")
if pos >= 0 {
msgData.RequestLine.Path = msgData.RequestLine.Uri[:pos]
} else {
msgData.RequestLine.Path = msgData.RequestLine.Uri
}
if h.defaultHandler == nil {
return payload.NewDataFrameResponse(payload.DataFrameResponseStatusCodeKHandlerNotFound), nil