From 4afc2e6ad66b253f40567b0eedef7934930ee091 Mon Sep 17 00:00:00 2001 From: sia Date: Fri, 13 Dec 2024 20:54:26 +0800 Subject: [PATCH] update blob --- router/default.go | 5 +++-- service/proxy.go | 3 +-- src/pages/index.tsx | 4 ---- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/router/default.go b/router/default.go index 2f4da30..47a1863 100644 --- a/router/default.go +++ b/router/default.go @@ -105,12 +105,13 @@ func NewRouter(c *cache.Redis) *mux.Router { http.Error(w, "bad address", 512) return } + fmt.Println(r.RequestURI) r.RequestURI = strings.TrimPrefix(r.RequestURI, "/blob") var address = fmt.Sprintf("https://raw.githubusercontent.com/%s/%s%s", - userBaisc[0], userBaisc[1], r.URL.Path) + userBaisc[0], userBaisc[1], r.RequestURI) path := fmt.Sprintf("raw.githubusercontent.com/%s/%s%s", userBaisc[0], userBaisc[1], r.URL.Path) - + fmt.Println(address) if c.Exists(path) { r.URL.Path = path http.FileServer(http.Dir("./cache/")).ServeHTTP(w, r) diff --git a/service/proxy.go b/service/proxy.go index f42ff6e..e9974f1 100644 --- a/service/proxy.go +++ b/service/proxy.go @@ -27,8 +27,7 @@ func PacketProxy(w http.ResponseWriter, r *http.Request, address string) { if !ok { v = []string{r.RemoteAddr} } - length, _ := strconv.Atoi(w.Header().Get("Content-Length")) - + length, _ := strconv.Atoi(r.Header.Get("Content-Length")) DefaultLogFormatter( LogFormatterParams{StatusCode: resp.StatusCode, ContentLength: humanize.Bytes(uint64(length)), ClientIP: v[0], Method: r.Method, Path: r.URL.Path}) diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 12deb2f..a0e733d 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -26,14 +26,10 @@ export default function Home() { - {/* */} - - -