good morning!!!!

Skip to content
Snippets Groups Projects
Commit cf96a410 authored by a's avatar a
Browse files

expose function

parent 25ecebc3
No related branches found
No related tags found
No related merge requests found
......@@ -10,26 +10,26 @@ type WebsocketServer struct {
}
func (s *WebsocketServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if isWebsocket(r) {
if IsWebsocket(r) {
s.s.WebsocketHandler([]string{"*"}).ServeHTTP(w, r)
return
}
s.s.ServeHTTP(w, r)
}
func isWebsocket(r *http.Request) bool {
func IsWebsocket(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
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment