Can't create routes named `index`, `show`
Reproduce
- Create a new project
bud create project - Create a root route (important)
bud new controller anything:/ index show -
bud new controller indexorbud new controller show(with or without views) -
bud runwill give an error:
| conjure: generate "bud/.app/main.go". conjure: generate "bud/.app/program/program.go". program: unable to wire. di: unable to wire "bud-app/bud/program".loadApp function. di: unable to find definition for param "bud-app/bud/.app/controller".*Controller in "bud-app/bud/.app/web".*Server . parser: unable to find declaration for "bud-app/bud/.app/controller".Controller in "bud/.app/web/web.go". bud/.app/controller/controller.go:15:2: Index redeclared in this block
previous declaration at bud/.app/controller/controller.go:13:2
Thanks for the report @012e! That's strange, but I'm not too surprised since it's untested. Just want to double-check. The 1/ directory in "1/bud/.app/controller" isn't related to #144 right?
Yes, 1 is just the module name.
My previous report was wrong so I rewrote it
Thanks! I can reproduce this one. Are you blocked by this one @012e? I may bundle this one together with reworking the controller generator to be middleware.
Are you blocked by this one @012e?
Not really, I don't need this
~~I was not able to reproduce this with the latest bud version 0.2.0~~
~~On a new bud project:~~
bud new controller foobar:/ index show
bud new controller index
~~Worked as expected with no errors~~
Disregard. I was able to reproduce it.
It is trying to create this during file generation (at the top of controller/controller.go).
// Controller struct
type Controller struct {
Index *IndexAction
Show *ShowAction
Index *IndexController
}
I'm looking at the .gotext files and experimenting with how feasible it would be to do the following instead:
// Controller struct
type Controller struct {
IndexAction *IndexAction
ShowAction *ShowAction
IndexController *IndexController
}
Edit:
I have it working this way now on a branch I'm toying with:
// Controller struct
type Controller struct {
Indexaction *IndexAction
Showaction *ShowAction
Index *IndexController
}
This also works at deeper levels of nesting, where the problem was occurring as well.