Skip to content

Commit

Permalink
improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
ehsannm committed Feb 13, 2022
1 parent 5ef4316 commit 900d83e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ go 1.17

require (
github.com/brianvoe/gofakeit/v6 v6.10.0
github.com/fasthttp/router v1.4.6
github.com/fasthttp/websocket v1.4.6
github.com/gobwas/ws v1.1.0
github.com/goccy/go-json v0.9.4
Expand Down
4 changes: 0 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ github.com/brianvoe/gofakeit/v6 v6.10.0/go.mod h1:palrJUk4Fyw38zIFB/uBZqsgzW5VsN
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/fasthttp/router v1.4.6 h1:KfETdHGBnvoBfBHeRe/8TVYz8Bp/mASBVC5UXO9CpZI=
github.com/fasthttp/router v1.4.6/go.mod h1:Iv800u3hYFNuBBcmJNs/VBVpub+JfBihGBp5spSocbw=
github.com/fasthttp/websocket v1.4.6 h1:Zi0Z6sUUvLmtxXd/kMLVBVJPvck3bqPqMWUbwhUy0R8=
github.com/fasthttp/websocket v1.4.6/go.mod h1:n0BlOQvJdPbTuBkZT0O5+jk/sp/1/VCzquR1BehI2F4=
github.com/gobwas/httphead v0.1.0 h1:exrUm0f4YX0L7EBwZHuCF4GDp8aJfVeBrlLQrs6NqWU=
Expand All @@ -28,8 +26,6 @@ github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/gorilla/websocket v1.4.1 h1:q7AeDBpnBk8AogcD4DSag/Ukw/KV+YhzLj2bP5HvKCM=
github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/klauspost/compress v1.14.1 h1:hLQYb23E8/fO+1u53d02A97a8UnsddcvYzq4ERRU4ds=
Expand Down
14 changes: 9 additions & 5 deletions std/bundle/fasthttp/bundle.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package fasthttp

import (
"bytes"
"encoding/json"
"fmt"
"net"
"sync"

"github.com/fasthttp/router"
"github.com/fasthttp/websocket"
"github.com/ronaksoft/ronykit"
"github.com/ronaksoft/ronykit/utils"
Expand Down Expand Up @@ -52,10 +52,14 @@ func New(opts ...Option) (*bundle, error) {
}

if r.wsEndpoint != "" {
entryRouter := router.New()
entryRouter.GET(r.wsEndpoint, r.wsHandler)
entryRouter.NotFound = r.httpHandler
r.srv.Handler = entryRouter.Handler
wsEndpoint := utils.S2B(r.wsEndpoint)
r.srv.Handler = func(ctx *fasthttp.RequestCtx) {
if ctx.IsGet() && bytes.EqualFold(ctx.Path(), wsEndpoint) {
r.wsHandler(ctx)
} else {
r.httpHandler(ctx)
}
}
} else {
r.srv.Handler = r.httpHandler
}
Expand Down

0 comments on commit 900d83e

Please sign in to comment.