Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] beego run statsviz has a javascript error #94

Open
zsy619 opened this issue Oct 30, 2022 · 5 comments
Open

[bug] beego run statsviz has a javascript error #94

zsy619 opened this issue Oct 30, 2022 · 5 comments
Assignees
Labels
backend Backend-related issues (Go module/server) bug Something isn't working waiting-for-info Waiting for extra information

Comments

@zsy619
Copy link

zsy619 commented Oct 30, 2022

代码如下:

package handler

import (
	"net/http/pprof"

	"github.com/arl/statsviz"
	"github.com/beego/beego/v2/server/web"
	"github.com/beego/beego/v2/server/web/context"
)

func init() {
	// web.Router(defaultPprofPrefix, &PprofController{}, "*:Index")
	web.AutoPrefix(defaultPprofPrefix, &PprofController{})
	// web.Router(defaultStatsvizPrefix, &PprofController{}, "*:StatIndex")
	// web.Router(defaultStatsvizPrefix+":path([\\w]+)", &PprofController{}, "*:StatPath")
	// web.Router(defaultStatsvizPrefix+"ws", &PprofController{}, "*:StatWs")

	web.Any("/debug/pprof/", func(ctx *context.Context) {
		pprof.Index(ctx.ResponseWriter, ctx.Request)
	})

	web.Any(defaultStatsvizPrefix, func(ctx *context.Context) {
		statsviz.Index.ServeHTTP(ctx.ResponseWriter, ctx.Request)
	})

	web.Any(defaultStatsvizPrefix+":path([\\w]+)", func(ctx *context.Context) {
		statsviz.Index.ServeHTTP(ctx.ResponseWriter, ctx.Request)
	})

	web.Any(defaultStatsvizPrefix+"ws", func(ctx *context.Context) {
		statsviz.Ws.ServeHTTP(ctx.ResponseWriter, ctx.Request)
	})
}

错误提示:
image

@arl arl added bug Something isn't working backend Backend-related issues (Go module/server) labels Nov 25, 2022
@arl
Copy link
Owner

arl commented Oct 9, 2023

@zsy619 Did you find the problem?

I'm sorry I don't know the beego library. However the examples directory shows how to configure statsviz with many other libraries/frameworks.

Maybe there's one that is similar to beego?

@arl arl added the waiting-for-info Waiting for extra information label Oct 10, 2023
@arl arl changed the title beego run statsviz has a javascript error [bug] beego run statsviz has a javascript error Oct 10, 2023
@mzzsfy
Copy link

mzzsfy commented Dec 21, 2023

web.Any(defaultStatsvizPrefix+":path([\\w]+)", func(ctx *context.Context) {
		statsviz.Index.ServeHTTP(ctx.ResponseWriter, ctx.Request)
	})

defaultStatsvizPrefix+":path([\\w]+)" It looks like it doesn't match the multi-level path, maybe it can be changed to defaultStatsvizPrefix+"*"

@arl
Copy link
Owner

arl commented Dec 21, 2023

I don't know beego myself, some examples have been added by the community. If you know how to fix that please don't hesitate to open a PR

@mzzsfy
Copy link

mzzsfy commented Dec 21, 2023

I don't know beego myself, some examples have been added by the community. If you know how to fix that please don't hesitate to open a PR

It seems to be a problem with his usage

@arl
Copy link
Owner

arl commented Dec 21, 2023

web.Any(defaultStatsvizPrefix+":path([\\w]+)", func(ctx *context.Context) {
		statsviz.Index.ServeHTTP(ctx.ResponseWriter, ctx.Request)
	})

defaultStatsvizPrefix+":path([\\w]+)" It looks like it doesn't match the multi-level path, maybe it can be changed to defaultStatsvizPrefix+"*"

@zsy619 did that solve the issue?
It's more than one year old so I'll soon close it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Backend-related issues (Go module/server) bug Something isn't working waiting-for-info Waiting for extra information
Projects
None yet
Development

No branches or pull requests

3 participants