e38a23b3 by astaxie

beego:admin add print method

1 parent 117904be
Showing 1 changed file with 24 additions and 0 deletions
...@@ -121,6 +121,10 @@ func listConf(rw http.ResponseWriter, r *http.Request) { ...@@ -121,6 +121,10 @@ func listConf(rw http.ResponseWriter, r *http.Request) {
121 fmt.Fprintln(rw, "AdminHttpPort:", AdminHttpPort) 121 fmt.Fprintln(rw, "AdminHttpPort:", AdminHttpPort)
122 case "router": 122 case "router":
123 fmt.Fprintln(rw, "Print all router infomation:") 123 fmt.Fprintln(rw, "Print all router infomation:")
124 for method, t := range BeeApp.Handlers.routers {
125 fmt.Fprintln(rw, "Method:", method)
126 printTree(rw, t)
127 }
124 // @todo print routers 128 // @todo print routers
125 case "filter": 129 case "filter":
126 fmt.Fprintln(rw, "Print all filter infomation:") 130 fmt.Fprintln(rw, "Print all filter infomation:")
...@@ -163,6 +167,26 @@ func listConf(rw http.ResponseWriter, r *http.Request) { ...@@ -163,6 +167,26 @@ func listConf(rw http.ResponseWriter, r *http.Request) {
163 } 167 }
164 } 168 }
165 169
170 func printTree(rw http.ResponseWriter, t *Tree) {
171 for _, tr := range t.fixrouters {
172 printTree(rw, tr)
173 }
174 if t.wildcard != nil {
175 printTree(rw, t.wildcard)
176 }
177 for _, l := range t.leaves {
178 if v, ok := l.runObject.(*controllerInfo); ok {
179 if v.routerType == routerTypeBeego {
180 fmt.Fprintln(rw, v.pattern, v.methods, v.controllerType.Name())
181 } else if v.routerType == routerTypeRESTFul {
182 fmt.Fprintln(rw, v.pattern, v.methods)
183 } else if v.routerType == routerTypeHandler {
184 fmt.Fprintln(rw, v.pattern, "handler")
185 }
186 }
187 }
188 }
189
166 // ProfIndex is a http.Handler for showing profile command. 190 // ProfIndex is a http.Handler for showing profile command.
167 // it's in url pattern "/prof" in admin module. 191 // it's in url pattern "/prof" in admin module.
168 func profIndex(rw http.ResponseWriter, r *http.Request) { 192 func profIndex(rw http.ResponseWriter, r *http.Request) {
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!