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

unable to upgrade reqlog.flusher to websocket websocket: response does not implement http.Hijacker using websocket #62

Closed
frederikhors opened this issue Apr 13, 2022 · 5 comments · Fixed by #63
Labels
enhancement New feature or request

Comments

@frederikhors
Copy link
Contributor

frederikhors commented Apr 13, 2022

I'm trying for the first time to use websockets (github.com/gorilla/websocket) with bunrouter.

I'm using

bunRouterOptions := []bunrouter.Option{
  // some...
}

bunRouterOptions = append(bunRouterOptions, bunrouter.Use(reqlog.NewMiddleware(reqlog.WithVerbose(true))))

router.Use(gqlgenDataloadersMiddleware).WithGroup("/graphql", func(group *bunrouter.Group) {
  group.GET("", bunrouter.HTTPHandler(gqlgenHandler))
  group.POST("", bunrouter.HTTPHandler(gqlgenHandler))
})

but I'm having this error:

unable to upgrade reqlog.flusher to websocket websocket: response does not implement http.Hijacker:
http: superfluous response.WriteHeader call from github.com/uptrace/bunrouter/extra/reqlog.(*statusCodeRecorder).WriteHeader (middleware.go:134)

If I comment the append reqlog.NewMiddleware line it works.

@vmihailenco
Copy link
Member

Looks like we need to add more wrappers like this for Hijack method - https://github.com/uptrace/bunrouter/blob/master/extra/reqlog/middleware.go#L137-L145. Could you send a PR?

@vmihailenco vmihailenco added the enhancement New feature or request label Apr 13, 2022
@frederikhors
Copy link
Contributor Author

I don't know how to start. 😢

@vmihailenco
Copy link
Member

No problem, looks like httpsnoop already handles all this.

@frederikhors
Copy link
Contributor Author

Do we have any news on the performances after this? Did you relaunch the benchmarks?

@vmihailenco
Copy link
Member

If you worry about performance - don't use reqlog. It is for debugging purposes and all benchmarks are done without such plugins.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants