Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clone router map before returning it to user #497

Merged
merged 3 commits into from
Oct 26, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion mux/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@

"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 11 in mux/router.go

View workflow job for this annotation

GitHub Actions / lint

File is not `goimports`-ed (goimports)
// TODO: switch to non-exp maps package when dependency hits 1.20
"golang.org/x/exp/maps"
)

type ResponseWriter = interface {
Expand Down Expand Up @@ -196,7 +198,7 @@
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
Loading