Skip to content

Commit b274d1d

Browse files
committed
remove gorilla/mux dependency
1 parent 5941063 commit b274d1d

3 files changed

Lines changed: 5 additions & 12 deletions

File tree

cmd/screen-server/webui.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
"github.com/function61/gokit/io/bidipipe"
1313
"github.com/function61/gokit/net/http/httputils"
1414
"github.com/function61/holepunch-server/pkg/wsconnadapter"
15-
"github.com/gorilla/mux"
1615
"github.com/gorilla/websocket"
1716
)
1817

@@ -47,14 +46,14 @@ var ui, _ = template.New("_").Parse(`<!doctype html>
4746
`)
4847

4948
func newServerHandler(screens []*Screen, logger *slog.Logger) http.Handler {
50-
routes := mux.NewRouter()
49+
routes := http.NewServeMux()
5150

5251
// serves VNC client etc.
53-
routes.PathPrefix("/static/").Handler(http.StripPrefix("/static/", http.FileServer(http.Dir("./www"))))
52+
routes.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("./www"))))
5453

5554
// websocket-to-VNC proxy
5655
routes.HandleFunc("/api/screen/{id}/ws", func(w http.ResponseWriter, r *http.Request) {
57-
id, err := strconv.Atoi(mux.Vars(r)["id"])
56+
id, err := strconv.Atoi(r.PathValue("id"))
5857
if err != nil {
5958
httputils.Error(w, http.StatusBadRequest)
6059
return
@@ -98,7 +97,7 @@ func newServerHandler(screens []*Screen, logger *slog.Logger) http.Handler {
9897
})
9998

10099
routes.HandleFunc("/api/screen/{id}/osd/notify", func(w http.ResponseWriter, r *http.Request) {
101-
id, err := strconv.Atoi(mux.Vars(r)["id"])
100+
id, err := strconv.Atoi(r.PathValue("id"))
102101
if err != nil {
103102
http.Error(w, err.Error(), http.StatusBadRequest)
104103
return
@@ -120,7 +119,7 @@ func newServerHandler(screens []*Screen, logger *slog.Logger) http.Handler {
120119
})
121120

122121
routes.HandleFunc("/api/screen/{id}/screenshot", func(w http.ResponseWriter, r *http.Request) {
123-
id, err := strconv.Atoi(mux.Vars(r)["id"])
122+
id, err := strconv.Atoi(r.PathValue("id"))
124123
if err != nil {
125124
http.Error(w, err.Error(), http.StatusBadRequest)
126125
return

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ require (
77
github.com/BurntSushi/xgbutil v0.0.0-20190907113008-ad855c713046
88
github.com/function61/gokit v0.0.0-20260109142558-7b125766c662
99
github.com/function61/holepunch-server v0.0.0-20200305174733-9c6de8210421
10-
github.com/gorilla/mux v1.7.4
1110
github.com/gorilla/websocket v1.4.1
1211
github.com/spf13/cobra v1.6.1
1312
)

go.sum

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
2323
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
2424
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
2525
github.com/function61/gokit v0.0.0-20200302141937-14d21ef1b462/go.mod h1:f6JhYQwMbwfAX472K/2A46CKet7BrpugMzuCobtqPQo=
26-
github.com/function61/gokit v0.0.0-20240321114127-797a00fcb45f h1:meF6JJLLrZuHWtVQrQ+o2mS+oEe4Dt0MyU+to8DxUio=
27-
github.com/function61/gokit v0.0.0-20240321114127-797a00fcb45f/go.mod h1:sJY957+7ush4oj4ElOMhUFaFIriAFNAGYzVh2tFJNy0=
2826
github.com/function61/gokit v0.0.0-20260109142558-7b125766c662 h1:JVKdsdHebFHuloQp3UQ3u76vBvUBm9jUwxcLXZSMl24=
2927
github.com/function61/gokit v0.0.0-20260109142558-7b125766c662/go.mod h1:ewGYmDoaszHKjwN9S2AM30oQwe4mhvuRUA4uvzzkmRw=
3028
github.com/function61/holepunch-server v0.0.0-20200305174733-9c6de8210421 h1:8yLWUK7RFUUdOxGZkLonn6ywERn33Uc4BvBJyLERnU0=
@@ -41,8 +39,6 @@ github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5y
4139
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
4240
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
4341
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
44-
github.com/gorilla/mux v1.7.4 h1:VuZ8uybHlWmqV03+zRzdwKL4tUnIp1MAQtp1mIFE1bc=
45-
github.com/gorilla/mux v1.7.4/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
4642
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
4743
github.com/gorilla/websocket v1.4.1 h1:q7AeDBpnBk8AogcD4DSag/Ukw/KV+YhzLj2bP5HvKCM=
4844
github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
@@ -116,7 +112,6 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h
116112
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
117113
golang.org/x/sys v0.0.0-20190801041406-cbf593c0f2f3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
118114
golang.org/x/sys v0.0.0-20200121082415-34d275377bf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
119-
golang.org/x/sys v0.0.0-20201101102859-da207088b7d1 h1:a/mKvvZr9Jcc8oKfcmgzyp7OwF73JPWsQLvH1z2Kxck=
120115
golang.org/x/sys v0.0.0-20201101102859-da207088b7d1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
121116
golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
122117
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=

0 commit comments

Comments
 (0)