Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Hijacking FastHTTP connection to usecoder/websocket? #506

Open
@SolomonSklash

Description

@SolomonSklash

Hello,

Instead of the Go standardnet/http, I am usingFastHTTP as my webserver, in order to upgrade to websockets usingFastHTTP 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//issues/229), this should be doable with using FastHttp'sfasthttp#RequestCtx.Hijack. From what I can tell, this will return the request context's underlyingnet.Conn object.

I am not sure how to make use of this within this websocket library. One total guess is somehow usingwebsocket.Accept, but I don't know how to provide the requiredResponseWriter andRequest.

Some guidance on this would be much appreciated!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp