mirror of
https://github.com/langgenius/dify-plugin-daemon.git
synced 2026-07-24 21:15:33 -04:00
fix: using validators to validate a map
This commit is contained in:
@@ -76,7 +76,9 @@ func TestInvokeEncrypt(t *testing.T) {
|
||||
http_invoked = true
|
||||
|
||||
ctx.JSON(http.StatusOK, gin.H{
|
||||
"key": "encrypted",
|
||||
"data": map[string]any{
|
||||
"key": "encrypted",
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
"github.com/langgenius/dify-plugin-daemon/internal/utils/stream"
|
||||
)
|
||||
|
||||
// Send a request to dify inner api and validate the response
|
||||
func Request[T any](i *RealBackwardsInvocation, method string, path string, options ...http_requests.HttpOptions) (*T, error) {
|
||||
options = append(options,
|
||||
http_requests.HttpHeader(map[string]string{
|
||||
@@ -89,10 +90,10 @@ func (i *RealBackwardsInvocation) InvokeEncrypt(payload *dify_invocation.InvokeE
|
||||
return payload.Data, nil
|
||||
}
|
||||
|
||||
data, err := Request[map[string]any](i, "POST", "invoke/encrypt", http_requests.HttpPayloadJson(payload))
|
||||
data, err := Request[dify_invocation.InvokeEncryptionResponse](i, "POST", "invoke/encrypt", http_requests.HttpPayloadJson(payload))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return *data, nil
|
||||
return data.Data, nil
|
||||
}
|
||||
|
||||
@@ -212,3 +212,8 @@ type InvokeNodeResponse struct {
|
||||
Outputs map[string]any `json:"outputs" validate:"required"`
|
||||
Inputs map[string]any `json:"inputs" validate:"required"`
|
||||
}
|
||||
|
||||
type InvokeEncryptionResponse struct {
|
||||
Error string `json:"error"`
|
||||
Data map[string]any `json:"data" validate:"required"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user