Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Hijacking FastHTTP connection to use `coder/websocket`?

Open
#506 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
30/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
go
Domain
api, backend

Research direction

Start by reviewing FastHTTP's RequestCtx.Hijack and the websocket.Accept API mentioned in the issue, focusing on how the hijacked net.Conn could be passed into the library. Determine how the required ResponseWriter and Request would be represented, then verify that a FastHTTP GET handler can complete a WebSocket upgrade and serve a connection.

Written by the indexing model from the issue text.

Description

needs-info

Hello,

Instead of the Go standard net/http, I am using FastHTTP as my webserver, in order to upgrade to websockets using FastHTTP websocket. It currently looks something like this, which is called by the GET handler of my FastHTTP server:

func websocketUpgradeHandler(ctx *fasthttp.RequestCtx) {
	logger.Infof("Received WS request on %s", string(ctx.Path()))

	// Upgrade the connection to a websocket.
	err := websockets.Upgrader.Upgrade(ctx, func(conn *websocket.Conn) {
		// Create a new WS connection object and give it the new WS connection.
		wsConnection := &websockets.WSConnection{Conn: conn}

		// Start the inbound WS worker goroutine.
		wsConnection.WSInboundWorker()
	})
	if err != nil {
		logger.Errorf("Failed to upgrade WS connection: %s", err)
	}
}

According to [#229 (https://github.com/coder/websocket/issues/229), this should be doable with using FastHttp's fasthttp#RequestCtx.Hijack. From what I can tell, this will return the request context's underlying net.Conn object.

I am not sure how to make use of this within this websocket library. One total guess is somehow using websocket.Accept, but I don't know how to provide the required ResponseWriter and Request.

Some guidance on this would be much appreciated!

Dominant language
Go
Stars
5.5k
Forks
377
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from coder/websocket

All issues in coder/websocket

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.