优化结构

This commit is contained in:
Yvan
2026-08-28 11:51:37 +08:00
parent 5b04998731
commit 33ba777137
25 changed files with 163 additions and 125 deletions
+13
View File
@@ -2,6 +2,7 @@ package httpx
import (
"net/http/httptest"
"strings"
"testing"
"github.com/gin-gonic/gin"
@@ -31,3 +32,15 @@ func TestResponseHelpers(t *testing.T) {
}
}
}
func TestSetCookieUsesRequestedName(t *testing.T) {
gin.SetMode(gin.TestMode)
r := gin.New()
r.GET("/cookie", func(c *gin.Context) { SetCookie(c, "example", "value", 60) })
req := httptest.NewRequest("GET", "/cookie", nil)
w := httptest.NewRecorder()
r.ServeHTTP(w, req)
if got := w.Header().Get("Set-Cookie"); !strings.HasPrefix(got, "example=") {
t.Fatalf("Set-Cookie = %q", got)
}
}