mirror of
https://github.com/kataras/iris.git
synced 2026-01-08 20:41:57 +00:00
Add a TODO on the latest HISTORY.md entry
Also disable version updater on Iris benchmark source code files. It may runs ever faster than before if you started the benchmarks immediately after the banner 👍
Former-commit-id: a55dc1e0b658d7386229c32ba6953b1ea60f2872
This commit is contained in:
@@ -165,6 +165,24 @@ func formatPath(path string) string {
|
||||
return path
|
||||
}
|
||||
|
||||
// StaticPath returns the static part of the original, registered route path.
|
||||
// if /user/{id} it will return /user
|
||||
// if /user/{id}/friend/{friendid:int} it will return /user too
|
||||
// if /assets/{filepath:path} it will return /assets.
|
||||
func (r Route) StaticPath() string {
|
||||
src := r.tmpl.Src
|
||||
bidx := strings.IndexByte(src, '{')
|
||||
if bidx == -1 || len(src) <= bidx {
|
||||
return src // no dynamic part found
|
||||
}
|
||||
if bidx == 0 { // found at first index,
|
||||
// but never happens because of the prepended slash
|
||||
return "/"
|
||||
}
|
||||
|
||||
return src[:bidx]
|
||||
}
|
||||
|
||||
// ResolvePath returns the formatted path's %v replaced with the args.
|
||||
func (r Route) ResolvePath(args ...string) string {
|
||||
rpath, formattedPath := r.Path, r.FormattedPath
|
||||
|
||||
Reference in New Issue
Block a user