MCPcopy Create free account
hub / github.com/kataras/iris / Handler

Function Handler

websocket/websocket.go:156–183  ·  view source on GitHub ↗

Handler returns an Iris handler to be served in a route of an Iris application. Accepts the neffos websocket server as its first input argument and optionally an Iris-specific `IDGenerator` as its second one. This SHOULD be the last handler in the route's chain as it hijacks the connection and the

(s *neffos.Server, idGenerator ...IDGenerator)

Source from the content-addressed store, hash-verified

154//
155// This SHOULD be the last handler in the route's chain as it hijacks the connection and the context.
156func Handler(s *neffos.Server, idGenerator ...IDGenerator) context.Handler {
157 idGen := DefaultIDGenerator
158 if len(idGenerator) > 0 {
159 idGen = idGenerator[0]
160 }
161
162 if cb := s.OnDisconnect; cb != nil {
163 s.OnDisconnect = func(c *neffos.Conn) {
164 cb(c)
165 manualReleaseWithoutResp(GetContext(c))
166 }
167 } else {
168 s.OnDisconnect = func(c *neffos.Conn) {
169 manualReleaseWithoutResp(GetContext(c))
170 }
171 }
172
173 return func(ctx *context.Context) {
174 if ctx.IsStopped() {
175 // let the framework release it as always;
176 // socket was not created so disconnect event will not called and the
177 // DisablePoolRelease was not even called yet.
178 return
179 }
180
181 Upgrade(ctx, idGen, s)
182 }
183}
184
185// Upgrade upgrades the request and returns a new websocket Conn.
186// Use `Handler` for higher-level implementation instead.

Callers 7

mainFunction · 0.92
mainFunction · 0.92
newAppFunction · 0.92
mainFunction · 0.92
mainFunction · 0.92
mainFunction · 0.92
SetupWebsocketsMethod · 0.92

Calls 4

manualReleaseWithoutRespFunction · 0.85
GetContextFunction · 0.85
UpgradeFunction · 0.85
IsStoppedMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…