Sfoglia il codice sorgente

feat: support Dify-Hook-Url

Yeuoly 5 mesi fa
parent
commit
b1674d960f
1 ha cambiato i file con 7 aggiunte e 0 eliminazioni
  1. 7 0
      internal/service/endpoint.go

+ 7 - 0
internal/service/endpoint.go

@@ -69,6 +69,13 @@ func Endpoint(
 
 	// setup hook id to request
 	req.Header.Set("Dify-Hook-Id", endpoint.HookID)
+	// check if Dify-Hook-Url is set
+	if url := req.Header.Get("Dify-Hook-Url"); url == "" {
+		req.Header.Set(
+			"Dify-Hook-Url",
+			fmt.Sprintf("http://%s:%s/e/%s%s", req.Host, req.URL.Port(), endpoint.HookID, path),
+		)
+	}
 
 	var buffer bytes.Buffer
 	err = req.Write(&buffer)