Skip to content

Commit

Permalink
Clone router map before returning it to user
Browse files Browse the repository at this point in the history
  • Loading branch information
HRogge committed Oct 18, 2023
1 parent 084c244 commit 9b5d983
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion mux/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import (
"io"
"sync"

// TODO: switch to non-exp maps package when dependency hits 1.20

Check failure on line 9 in mux/router.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gci`-ed with --skip-generated -s standard -s default (gci)
"golang.org/x/exp/maps"

"github.com/plgd-dev/go-coap/v3/message"
"github.com/plgd-dev/go-coap/v3/message/codes"
"github.com/plgd-dev/go-coap/v3/message/pool"

Check failure on line 14 in mux/router.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gci`-ed with --skip-generated -s standard -s default (gci)
Expand Down Expand Up @@ -187,7 +190,7 @@ func (r *Router) GetRoute(pattern string) *Route {
func (r *Router) GetRoutes() map[string]Route {
r.m.RLock()
defer r.m.RUnlock()
return r.z
return maps.Clone(r.z)
}

// ServeCOAP dispatches the request to the handler whose
Expand Down

0 comments on commit 9b5d983

Please sign in to comment.