refactor: Refactor retriever engine checks and expose mapping

This commit is contained in:
begoniezhao
2026-01-12 17:34:01 +08:00
parent e023c26af8
commit 389900af7e
3 changed files with 30 additions and 30 deletions
-28
View File
@@ -4,10 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"net"
"net/http"
"net/url"
"strings"
"time"
"github.com/Tencent/WeKnora/internal/logger"
@@ -61,31 +58,6 @@ type mcpGoClient struct {
initialized bool
}
// validateURLScheme validates that authentication endpoints use HTTPS
func validateURLScheme(serviceURL string, hasBasicAuth bool, hasTokenAuth bool) error {
if !hasBasicAuth && !hasTokenAuth {
// No authentication, no HTTPS requirement
return nil
}
if serviceURL == "" {
return fmt.Errorf("URL is required")
}
// Parse the URL
parsedURL, err := url.Parse(serviceURL)
if err != nil {
return fmt.Errorf("invalid URL: %w", err)
}
// Enforce HTTPS for authenticated endpoints
if parsedURL.Scheme != "https" {
return fmt.Errorf("HTTPS is required for authenticated connections, got %s scheme", parsedURL.Scheme)
}
return nil
}
// NewMCPClient creates a new MCP client based on the transport type
func NewMCPClient(config *ClientConfig) (MCPClient, error) {
// Create HTTP client with timeout