]> 127.0.0.1 Git - front/.git/commitdiff
1 v0.1.20250328181930
authorqydysky <qydysky@foxmail.com>
Fri, 28 Mar 2025 18:17:34 +0000 (02:17 +0800)
committerqydysky <qydysky@foxmail.com>
Fri, 28 Mar 2025 18:17:34 +0000 (02:17 +0800)
config_test.go
go.mod
go.sum

index 9f081af36af3c7cd6cc368f5825cc389354b9cbc..06c7c0b29847b01055908ad5204bf43436007972 100644 (file)
@@ -24,6 +24,63 @@ var logger = plog.New(plog.Config{
        },
 })
 
+func Test_Uri2(t *testing.T) {
+       ctx, cancel := context.WithCancel(context.Background())
+       defer cancel()
+
+       web := pweb.New(&http.Server{
+               Addr: "127.0.0.1:19001",
+       })
+       web.Handle(map[string]func(http.ResponseWriter, *http.Request){
+               `//test/`: func(w http.ResponseWriter, r *http.Request) {
+                       io.Copy(w, r.Body)
+               },
+       })
+
+       defer web.Shutdown()
+
+       conf := &Config{
+               Addr: "127.0.0.1:19000",
+               Routes: []Route{
+                       {
+                               Path:    []string{"//test/"},
+                               PathAdd: true,
+                               Backs: []Back{
+                                       {
+                                               Name:   "1",
+                                               To:     "://127.0.0.1:19001",
+                                               Weight: 1,
+                                       },
+                               },
+                       },
+               },
+       }
+
+       go conf.Run(ctx, logger)
+
+       time.Sleep(time.Second)
+
+       reqb := []byte("1234")
+       resb := make([]byte, 5)
+
+       pipe := reqf.NewRawReqRes()
+       r := reqf.New()
+       if e := r.Reqf(reqf.Rval{
+               Url:     "http://127.0.0.1:19000//test/",
+               RawPipe: pipe,
+               Async:   true,
+       }); e != nil {
+               t.Fatal()
+       }
+       pipe.ReqWrite(reqb)
+       pipe.ReqClose()
+       n, _ := pipe.ResRead(resb)
+       resb = resb[:n]
+       if !bytes.Equal(resb, reqb) {
+               t.Fatal(string(resb))
+       }
+}
+
 func Test_Uri(t *testing.T) {
        ctx, cancel := context.WithCancel(context.Background())
        defer cancel()
diff --git a/go.mod b/go.mod
index b5b5df9959a4a1d1db77f768c04b6f342a21a08a..a64185fddd4f9ac384751102a40f316ca59fb24d 100755 (executable)
--- a/go.mod
+++ b/go.mod
@@ -5,7 +5,7 @@ go 1.24
 require (
        github.com/dustin/go-humanize v1.0.1
        github.com/gorilla/websocket v1.5.3
-       github.com/qydysky/part v0.28.20250328130819
+       github.com/qydysky/part v0.28.20250328181619
        golang.org/x/net v0.37.0
 )
 
diff --git a/go.sum b/go.sum
index 09c0dd5ec809c55e1e5bced3aa71033be6effc54..924d6a3af28eb05baafe36441fa605fd19681e6a 100755 (executable)
--- a/go.sum
+++ b/go.sum
@@ -27,8 +27,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
 github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
 github.com/qydysky/brotli v0.0.0-20240828134800-e9913a6e7ed9 h1:k451T+bpsLr+Dq9Ujo+Qtx0iomRA1XXS5ttlEojvfuQ=
 github.com/qydysky/brotli v0.0.0-20240828134800-e9913a6e7ed9/go.mod h1:cI8/gy/wjy2Eb+p2IUj2ZuDnC8R5Vrx3O0VMPvMvphA=
-github.com/qydysky/part v0.28.20250328130819 h1:rgsbvxfT15lmmKUI+6pFntLhLLdDr0EBFBaIxGg+sjI=
-github.com/qydysky/part v0.28.20250328130819/go.mod h1:RHYTy8EbqCP6OioVf6BkvFcfWLNO0S220zl0DDlY84Y=
+github.com/qydysky/part v0.28.20250328181619 h1:YaFb1luuYxKoxH7il5non/ILyRL2XGAGWS6Z640QhcM=
+github.com/qydysky/part v0.28.20250328181619/go.mod h1:RHYTy8EbqCP6OioVf6BkvFcfWLNO0S220zl0DDlY84Y=
 github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
 github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
 github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI=