diff --git a/iris.go b/iris.go index bb7dc523..7333b844 100644 --- a/iris.go +++ b/iris.go @@ -128,7 +128,7 @@ func (s *Iris) initTemplates() { return "", ErrRenderRouteNotFound.Format(routeName) } - if result, ok := r.parse(args...); ok { + if result, ok := r.Parse(args...); ok { return result, nil } return "", nil diff --git a/route.go b/route.go index 6ed79b61..8f16bca9 100644 --- a/route.go +++ b/route.go @@ -18,8 +18,9 @@ type ( Name(string) IRoute GetMiddleware() Middleware HasCors() bool - // used internaly to check arguments with the route's named parameters - parse(...interface{}) (string, bool) + // used to check arguments with the route's named parameters and return the correct url + // second parameter is false when the action cannot be done + Parse(...interface{}) (string, bool) } // RouteNameFunc is returned to from route handle @@ -148,8 +149,7 @@ func (r *Route) HasCors() bool { 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 ///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