mirror of
https://github.com/kataras/iris.git
synced 2025-02-02 15:30:36 +01:00
make Route's parse public
This commit is contained in:
parent
56a9fba34d
commit
79e984146e
2
iris.go
2
iris.go
|
@ -128,7 +128,7 @@ func (s *Iris) initTemplates() {
|
||||||
return "", ErrRenderRouteNotFound.Format(routeName)
|
return "", ErrRenderRouteNotFound.Format(routeName)
|
||||||
}
|
}
|
||||||
|
|
||||||
if result, ok := r.parse(args...); ok {
|
if result, ok := r.Parse(args...); ok {
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
return "", nil
|
return "", nil
|
||||||
|
|
8
route.go
8
route.go
|
@ -18,8 +18,9 @@ type (
|
||||||
Name(string) IRoute
|
Name(string) IRoute
|
||||||
GetMiddleware() Middleware
|
GetMiddleware() Middleware
|
||||||
HasCors() bool
|
HasCors() bool
|
||||||
// used internaly to check arguments with the route's named parameters
|
// used to check arguments with the route's named parameters and return the correct url
|
||||||
parse(...interface{}) (string, bool)
|
// second parameter is false when the action cannot be done
|
||||||
|
Parse(...interface{}) (string, bool)
|
||||||
}
|
}
|
||||||
|
|
||||||
// RouteNameFunc is returned to from route handle
|
// RouteNameFunc is returned to from route handle
|
||||||
|
@ -148,8 +149,7 @@ func (r *Route) HasCors() bool {
|
||||||
return RouteConflicts(r, "httpmethod")
|
return RouteConflicts(r, "httpmethod")
|
||||||
}
|
}
|
||||||
|
|
||||||
// used internaly to check arguments with the route's named parameters (iris.initTemplates for funcs)
|
func (r *Route) Parse(args ...interface{}) (string, bool) {
|
||||||
func (r *Route) parse(args ...interface{}) (string, bool) {
|
|
||||||
// check if arguments are not equal to the named parameters ( : = 1, * = all named parameters split to / ), if this happens then send not found err
|
// check if arguments are not equal to the named parameters ( : = 1, * = all named parameters split to / ), if this happens then send not found err
|
||||||
///TODO: I'm thinking of making an option to disable these checks and just return a result, because they have cost when rendering an html/template, not too big compared to the render action but... we will see
|
///TODO: I'm thinking of making an option to disable these checks and just return a result, because they have cost when rendering an html/template, not too big compared to the render action but... we will see
|
||||||
// can also do a check if this url can be realy served (_tree.rootBranch.GetBranch(path, ctx.Params)) and if not then return a 404 or a link to a ./templates/errors/404.html
|
// can also do a check if this url can be realy served (_tree.rootBranch.GetBranch(path, ctx.Params)) and if not then return a 404 or a link to a ./templates/errors/404.html
|
||||||
|
|
Loading…
Reference in New Issue
Block a user