style(amp): tidy whitespace in proxy module and tests

This commit is contained in:
hkfires
2025-11-26 18:57:26 +08:00
parent a4a26d978e
commit 6c17dbc4da
6 changed files with 30 additions and 33 deletions

View File

@@ -181,5 +181,3 @@ func (m *AmpModule) OnConfigUpdated(cfg *config.Config) error {
log.Debug("Amp config updated (restart required for URL changes)") log.Debug("Amp config updated (restart required for URL changes)")
return nil return nil
} }

View File

@@ -129,8 +129,8 @@ func createReverseProxy(upstreamURL string, secretSource SecretSource) (*httputi
resp.ContentLength = int64(len(decompressed)) resp.ContentLength = int64(len(decompressed))
// Update headers to reflect decompressed state // Update headers to reflect decompressed state
resp.Header.Del("Content-Encoding") // No longer compressed resp.Header.Del("Content-Encoding") // No longer compressed
resp.Header.Del("Content-Length") // Remove stale compressed length resp.Header.Del("Content-Length") // Remove stale compressed length
resp.Header.Set("Content-Length", strconv.FormatInt(resp.ContentLength, 10)) // Set decompressed length resp.Header.Set("Content-Length", strconv.FormatInt(resp.ContentLength, 10)) // Set decompressed length
log.Debugf("amp proxy: decompressed gzip response (%d -> %d bytes)", len(gzippedData), len(decompressed)) log.Debugf("amp proxy: decompressed gzip response (%d -> %d bytes)", len(gzippedData), len(decompressed))

View File

@@ -440,52 +440,52 @@ func TestIsStreamingResponse(t *testing.T) {
func TestFilterBetaFeatures(t *testing.T) { func TestFilterBetaFeatures(t *testing.T) {
tests := []struct { tests := []struct {
name string name string
header string header string
featureToRemove string featureToRemove string
expected string expected string
}{ }{
{ {
name: "Remove context-1m from middle", name: "Remove context-1m from middle",
header: "fine-grained-tool-streaming-2025-05-14,context-1m-2025-08-07,oauth-2025-04-20", header: "fine-grained-tool-streaming-2025-05-14,context-1m-2025-08-07,oauth-2025-04-20",
featureToRemove: "context-1m-2025-08-07", featureToRemove: "context-1m-2025-08-07",
expected: "fine-grained-tool-streaming-2025-05-14,oauth-2025-04-20", expected: "fine-grained-tool-streaming-2025-05-14,oauth-2025-04-20",
}, },
{ {
name: "Remove context-1m from start", name: "Remove context-1m from start",
header: "context-1m-2025-08-07,fine-grained-tool-streaming-2025-05-14", header: "context-1m-2025-08-07,fine-grained-tool-streaming-2025-05-14",
featureToRemove: "context-1m-2025-08-07", featureToRemove: "context-1m-2025-08-07",
expected: "fine-grained-tool-streaming-2025-05-14", expected: "fine-grained-tool-streaming-2025-05-14",
}, },
{ {
name: "Remove context-1m from end", name: "Remove context-1m from end",
header: "fine-grained-tool-streaming-2025-05-14,context-1m-2025-08-07", header: "fine-grained-tool-streaming-2025-05-14,context-1m-2025-08-07",
featureToRemove: "context-1m-2025-08-07", featureToRemove: "context-1m-2025-08-07",
expected: "fine-grained-tool-streaming-2025-05-14", expected: "fine-grained-tool-streaming-2025-05-14",
}, },
{ {
name: "Feature not present", name: "Feature not present",
header: "fine-grained-tool-streaming-2025-05-14,oauth-2025-04-20", header: "fine-grained-tool-streaming-2025-05-14,oauth-2025-04-20",
featureToRemove: "context-1m-2025-08-07", featureToRemove: "context-1m-2025-08-07",
expected: "fine-grained-tool-streaming-2025-05-14,oauth-2025-04-20", expected: "fine-grained-tool-streaming-2025-05-14,oauth-2025-04-20",
}, },
{ {
name: "Only feature to remove", name: "Only feature to remove",
header: "context-1m-2025-08-07", header: "context-1m-2025-08-07",
featureToRemove: "context-1m-2025-08-07", featureToRemove: "context-1m-2025-08-07",
expected: "", expected: "",
}, },
{ {
name: "Empty header", name: "Empty header",
header: "", header: "",
featureToRemove: "context-1m-2025-08-07", featureToRemove: "context-1m-2025-08-07",
expected: "", expected: "",
}, },
{ {
name: "Header with spaces", name: "Header with spaces",
header: "fine-grained-tool-streaming-2025-05-14, context-1m-2025-08-07 , oauth-2025-04-20", header: "fine-grained-tool-streaming-2025-05-14, context-1m-2025-08-07 , oauth-2025-04-20",
featureToRemove: "context-1m-2025-08-07", featureToRemove: "context-1m-2025-08-07",
expected: "fine-grained-tool-streaming-2025-05-14,oauth-2025-04-20", expected: "fine-grained-tool-streaming-2025-05-14,oauth-2025-04-20",
}, },
} }

View File

@@ -6,11 +6,11 @@ import (
"strings" "strings"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/router-for-me/CLIProxyAPI/v6/internal/util"
"github.com/router-for-me/CLIProxyAPI/v6/sdk/api/handlers" "github.com/router-for-me/CLIProxyAPI/v6/sdk/api/handlers"
"github.com/router-for-me/CLIProxyAPI/v6/sdk/api/handlers/claude" "github.com/router-for-me/CLIProxyAPI/v6/sdk/api/handlers/claude"
"github.com/router-for-me/CLIProxyAPI/v6/sdk/api/handlers/gemini" "github.com/router-for-me/CLIProxyAPI/v6/sdk/api/handlers/gemini"
"github.com/router-for-me/CLIProxyAPI/v6/sdk/api/handlers/openai" "github.com/router-for-me/CLIProxyAPI/v6/sdk/api/handlers/openai"
"github.com/router-for-me/CLIProxyAPI/v6/internal/util"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
) )

View File

@@ -826,7 +826,6 @@ func (r *ModelRegistry) CleanupExpiredQuotas() {
} }
} }
// GetFirstAvailableModel returns the first available model for the given handler type. // GetFirstAvailableModel returns the first available model for the given handler type.
// It prioritizes models by their creation timestamp (newest first) and checks if they have // It prioritizes models by their creation timestamp (newest first) and checks if they have
// available clients that are not suspended or over quota. // available clients that are not suspended or over quota.

View File

@@ -71,7 +71,7 @@ func (h *GeminiAPIHandler) GeminiGetHandler(c *gin.Context) {
switch request.Action { switch request.Action {
case "gemini-3-pro-preview": case "gemini-3-pro-preview":
c.JSON(http.StatusOK, gin.H{ c.JSON(http.StatusOK, gin.H{
"name": "gemini-3-pro-preview", "name": "models/gemini-3-pro-preview",
"version": "3", "version": "3",
"displayName": "Gemini 3 Pro Preview", "displayName": "Gemini 3 Pro Preview",
"description": "Gemini 3 Pro Preview", "description": "Gemini 3 Pro Preview",