Ok.. I have, or am writing a web framework package, called mao.
I'd like to have my Route defined in the controller.
in mao
type (
Controller struct {
Route Route
}
Route struct {
Name, Host, Path, Method string
}
)
in mao importing package
controller/default.go
type DefaultController struct {
mao.Controller
}
func (this *DefaultController) Index() Response {
this.Route = mao.Route{"default_index","localhost","/", "GET"}
}
Now since I'd like to define my route inside the controller, the router, when instanced should read all controllers. That's the problem.
How do I pass the package name to my router so it's able to get all structs and functions in that package? Is it even possible?