@@ -161,7 +161,7 @@ func (r *Route) BuildHandlers() {
161161}
162162
163163// String returns the form of METHOD, SUBDOMAIN, TMPL PATH.
164- func (r Route ) String () string {
164+ func (r * Route ) String () string {
165165 return fmt .Sprintf ("%s %s%s" ,
166166 r .Method , r .Subdomain , r .Tmpl ().Src )
167167}
@@ -214,13 +214,13 @@ func (r *Route) SetPriority(prio float32) *Route {
214214// Developer can get his registered path
215215// via Tmpl().Src, Route.Path is the path
216216// converted to match the underline router's specs.
217- func (r Route ) Tmpl () macro.Template {
217+ func (r * Route ) Tmpl () macro.Template {
218218 return r .tmpl
219219}
220220
221221// RegisteredHandlersLen returns the end-developer's registered handlers, all except the macro evaluator handler
222222// if was required by the build process.
223- func (r Route ) RegisteredHandlersLen () int {
223+ func (r * Route ) RegisteredHandlersLen () int {
224224 n := len (r .Handlers )
225225 if handler .CanMakeHandler (r .tmpl ) {
226226 n --
@@ -230,7 +230,7 @@ func (r Route) RegisteredHandlersLen() int {
230230}
231231
232232// IsOnline returns true if the route is marked as "online" (state).
233- func (r Route ) IsOnline () bool {
233+ func (r * Route ) IsOnline () bool {
234234 return r .Method != MethodNone
235235}
236236
@@ -270,11 +270,18 @@ func formatPath(path string) string {
270270 return path
271271}
272272
273+ // IsStatic reports whether this route is a static route.
274+ // Does not contain dynamic path parameters,
275+ // is online and registered on GET HTTP Method.
276+ func (r * Route ) IsStatic () bool {
277+ return r .IsOnline () && len (r .Tmpl ().Params ) == 0 && r .Method == "GET"
278+ }
279+
273280// StaticPath returns the static part of the original, registered route path.
274281// if /user/{id} it will return /user
275282// if /user/{id}/friend/{friendid:uint64} it will return /user too
276283// if /assets/{filepath:path} it will return /assets.
277- func (r Route ) StaticPath () string {
284+ func (r * Route ) StaticPath () string {
278285 src := r .tmpl .Src
279286 bidx := strings .IndexByte (src , '{' )
280287 if bidx == - 1 || len (src ) <= bidx {
@@ -289,7 +296,7 @@ func (r Route) StaticPath() string {
289296}
290297
291298// ResolvePath returns the formatted path's %v replaced with the args.
292- func (r Route ) ResolvePath (args ... string ) string {
299+ func (r * Route ) ResolvePath (args ... string ) string {
293300 rpath , formattedPath := r .Path , r .FormattedPath
294301 if rpath == formattedPath {
295302 // static, no need to pass args
@@ -310,7 +317,7 @@ func (r Route) ResolvePath(args ...string) string {
310317
311318// Trace returns some debug infos as a string sentence.
312319// Should be called after Build.
313- func (r Route ) Trace () string {
320+ func (r * Route ) Trace () string {
314321 printfmt := fmt .Sprintf ("[%s:%d] %s:" , r .SourceFileName , r .SourceLineNumber , r .Method )
315322 if r .Subdomain != "" {
316323 printfmt += fmt .Sprintf (" %s" , r .Subdomain )
0 commit comments