-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Routes generation #39
Comments
This is ready, now we need a new router (or a wrapper around existing router) that would support the generated format. |
Good! Be quick! |
Some early version of routes generation has been implemented. Packages TODO: add support of custom 404 and 405 errors without use of ugly global variables in the router. I'm thinking about adding an optional third parameter to the route: //@get /errors/404 SOME_PARAMETER_HERE
func (c *App) Error404() http.Handler {
...
} We'll use it to let a router know we want this action to be used in case of |
Very good you do ! |
I'm working on the next iteration of Goal and rethinking everything. At the moment I'm undecided how far we want to go with the code generation. Do we really need the feature this GH issue introduces? Or do we have to roll back to the |
Routes in Goal
Goal's
routes
package in the auto generatedskeleton
app is nothing more than a globalList
variable and calls to the default router:routes
package and write there whatever code he/she needs.r.Get
will be compiled,r.Gte
wont be;h.Controller.Action
will,h.Controller.Atcion
wont, etc).routes.go
to reflect that addition.routes.go
(so we'll have to introduce Goal specific code or convention).Proposal
Use annotation like syntax. E.g. in Bottle.py there is:
There are no annotations in Go, but other tools such as
go generate
andgo build
use tags in comments. That's what we can do, too:Import of actions
Controllers end-developer embeds may include actions with routes. Those can be prefixed as follows:
Result of generation
It is supposed the generated code will be similar to:
This
Routes
then can be used by the router (after importing the package where it's located).For now the variable should be located within generated
handlers
package (as it is easy to implement). After MVP version will require generation of a newroutes
package in./assets/
.Reverse routing
We'll use controllers to generate both
routes
andreverse routes
. A new issue must be open for the latter.The text was updated successfully, but these errors were encountered: