good morning!!!!
Skip to content
GitLab
Explore
Sign in
Commits on Source (1)
expose function
· cf96a410
a
authored
Mar 11, 2023
cf96a410
Hide whitespace changes
Inline
Side-by-side
websocket_server.go
View file @
cf96a410
...
...
@@ -10,26 +10,26 @@ type WebsocketServer struct {
}
func
(
s
*
WebsocketServer
)
ServeHTTP
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
if
i
sWebsocket
(
r
)
{
if
I
sWebsocket
(
r
)
{
s
.
s
.
WebsocketHandler
([]
string
{
"*"
})
.
ServeHTTP
(
w
,
r
)
return
}
s
.
s
.
ServeHTTP
(
w
,
r
)
}
func
i
sWebsocket
(
r
*
http
.
Request
)
bool
{
func
I
sWebsocket
(
r
*
http
.
Request
)
bool
{
return
strings
.
EqualFold
(
r
.
Header
.
Get
(
"Upgrade"
),
"websocket"
)
&&
strings
.
Contains
(
strings
.
ToLower
(
r
.
Header
.
Get
(
"Connection"
)),
"upgrade"
)
}
func
(
s
*
Server
)
ServeHTTPWithWss
(
cb
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
bool
)
http
.
Handler
{
return
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
if
isWebsocket
(
r
)
{
if
cb
!=
nil
{
if
cb
(
w
,
r
)
{
return
}
if
cb
!=
nil
{
if
cb
(
w
,
r
)
{
return
}
}
if
IsWebsocket
(
r
)
{
s
.
WebsocketHandler
([]
string
{
"*"
})
.
ServeHTTP
(
w
,
r
)
return
}
...
...