bsed / gorilla

Automatically exported from code.google.com/p/gorilla
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

[mux] Request for adding a Name field to Route struct #24

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
It would be nice if we can query a matched Route and get the route name 
associated with it. Currently, Router creates a NamedRoutes map with the given 
unique name but there is no way to retrieve the matched route name. This will 
be helpful, for an example, where you don't want mux to servehttp request but 
to just act as a matcher. I'd like to handle the servehttp logic myself but 
want to know which route was matched (which mux already supports) but I also 
need a name.

The Name field can be package scoped (hence 'name') in which case a getter is 
needed. Something like:

func (r *Router) GetName() string{
   return r.name
}

I've read the mux code and it looks trivial to implement this request. No extra 
logic is needed just a field and a method.

This will make my life much easier on a project that I'm working on.

Original issue reported on code.google.com by ashokgelal on 27 Oct 2011 at 4:35

GoogleCodeExporter commented 9 years ago
Cloned it and implemented this (http://code.google.com/r/ashokgelal-gorilla/). 
Also, added a test. Please let me know if this is okay.

Original comment by ashokgelal on 27 Oct 2011 at 5:35

GoogleCodeExporter commented 9 years ago
Yep, this is useful, and your changes look good. 

Only one thing: when cloning a route, name can be left empty, because name 
should only be set if the route is registered in the router. And we don't want 
two routes with same name anyway. Agree?

Original comment by rodrigo.moraes on 28 Oct 2011 at 11:26

GoogleCodeExporter commented 9 years ago

Original comment by rodrigo.moraes on 28 Oct 2011 at 11:28

GoogleCodeExporter commented 9 years ago
I agree that a clone needs to have its own name. Thanks for accepting the 
ticket.

Original comment by ashokgelal on 28 Oct 2011 at 3:42

GoogleCodeExporter commented 9 years ago
Hey, I'm pulling your changes. What is your name? It's for the credits.

Original comment by rodrigo.moraes on 29 Oct 2011 at 9:36

GoogleCodeExporter commented 9 years ago
Ashok Gelal! :) 

Found it here: https://github.com/ashokgelal

Original comment by rodrigo.moraes on 29 Oct 2011 at 9:49

GoogleCodeExporter commented 9 years ago
This issue was closed by revision b79899a6f0b7.

Original comment by rodrigo.moraes on 29 Oct 2011 at 9:50