Skip to content

Instantly share code, notes, and snippets.

@grampelberg
Created January 20, 2020 01:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grampelberg/006dcfb5d959873c6bee0cc894d16570 to your computer and use it in GitHub Desktop.
Save grampelberg/006dcfb5d959873c6bee0cc894d16570 to your computer and use it in GitHub Desktop.
func routes() []string {
raw := reflect.ValueOf(http.DefaultServeMux).Elem().FieldByName("m")
raw = reflect.NewAt(raw.Type(), unsafe.Pointer(raw.UnsafeAddr())).Elem()
var rts []string
for _, k := range raw.MapKeys() {
rts = append(rts, k.String())
}
sort.Strings(rts)
return rts
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment