Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
corteza
corteza-server
Commits
7c6b6048
Commit
7c6b6048
authored
6 years ago
by
Tit Petric
Browse files
Options
Download
Email Patches
Plain Diff
refenerate routes
parent
aa6b3e94
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
1 deletion
+19
-1
crm/routes.go
crm/routes.go
+0
-1
crm/templates/http_routes.tpl
crm/templates/http_routes.tpl
+19
-0
No files found.
crm/routes.go
View file @
7c6b6048
...
...
@@ -34,7 +34,6 @@ func MountRoutes(r chi.Router) {
})
r
.
Route
(
"/types"
,
func
(
r
chi
.
Router
)
{
r
.
Get
(
"/list"
,
types
.
List
)
r
.
Post
(
"/list"
,
types
.
List
)
r
.
Get
(
"/type/{id}"
,
types
.
Type
)
})
...
...
This diff is collapsed.
Click to expand it.
crm/templates/http_routes.tpl
View file @
7c6b6048
...
...
@@ -3,6 +3,9 @@ package {package}
{
load
warning
.
tpl
}
import (
"fmt"
"runtime"
"reflect"
"github.com/go-chi/chi"
)
...
...
@@ -17,4 +20,20 @@ func MountRoutes(r chi.Router) {
{/
foreach
}
})
{/
foreach
}
var printRoutes func(chi.Routes, string, string)
printRoutes = func(r chi.Routes, indent string, prefix string) {
routes := r.Routes()
for _, route := range routes {
if route.SubRoutes != nil
&&
len(route.SubRoutes.Routes()) > 0 {
fmt.Printf(indent+"%s - with %d handlers, %d subroutes\n", route.Pattern, len(route.Handlers), len(route.SubRoutes.Routes()))
printRoutes(route.SubRoutes, indent+"\t", prefix+route.Pattern[:len(route.Pattern)-2])
} else {
for key, fn := range route.Handlers {
fmt.Printf("%s%s\t%s -> %s\n", indent, key, prefix+route.Pattern, runtime.FuncForPC(reflect.ValueOf(fn).Pointer()).Name())
}
}
}
}
printRoutes(r, "", "")
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment