From 02808390cafe3e8bb1e9f9a761904ca9e256701e Mon Sep 17 00:00:00 2001 From: rulingcom Date: Sat, 22 Apr 2023 00:10:45 +0800 Subject: [PATCH] fix error for proxy --- charts.go | 7 ++++--- main.go | 8 +++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/charts.go b/charts.go index e19b6d6..927c3b9 100644 --- a/charts.go +++ b/charts.go @@ -28,8 +28,8 @@ import ( var assetsFS embed.FS var ( - assetsPath = "/echarts/statics/" - apiPath = "/data/" + assetsPath = "/admin/plow/echarts/statics/" + apiPath = "/admin/plow/data/" latencyView = "latency" rpsView = "rps" timeFormat = "15:04:05" @@ -64,7 +64,7 @@ function {{ .ViewID }}_sync() { {{- template "header" . }} -

🚀 Plow %s

+

🚀 Plow %s

{{- range .Charts }} {{ template "base" . }} {{- end }}
@@ -202,6 +202,7 @@ func (c *Charts) Handler(ctx *fasthttp.RequestCtx) { ctx.Error(err.Error(), 404) } else { ctx.SetBodyStream(f, -1) + ctx.SetContentType("application/x-javascript") } } else { ctx.Error("NotFound", fasthttp.StatusNotFound) diff --git a/main.go b/main.go index f063de7..f12fe6b 100644 --- a/main.go +++ b/main.go @@ -5,6 +5,7 @@ import ( "net" "net/http" _ "net/http/pprof" + URI "net/url" "os" "strconv" "strings" @@ -256,7 +257,12 @@ func main() { // description var desc string - desc = fmt.Sprintf("Benchmarking %s", *url) + if *host != "" { + uri, _ := URI.Parse(*url) + desc = fmt.Sprintf("Benchmarking %s://%s%s", uri.Scheme, *host, uri.RequestURI()) + }else{ + desc = fmt.Sprintf("Benchmarking %s", *url) + } if *requests > 0 { desc += fmt.Sprintf(" with %d request(s)", *requests) }