Skip to content
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

Can't create routes named index, show #149

Closed
012e opened this issue Jun 23, 2022 · 7 comments
Closed

Can't create routes named index, show #149

012e opened this issue Jun 23, 2022 · 7 comments
Labels
bug Something isn't working help wanted We'd love your help!

Comments

@012e
Copy link
Contributor

012e commented Jun 23, 2022

Reproduce

  1. Create a new project bud create project
  2. Create a root route (important) bud new controller anything:/ index show
  3. bud new controller index or bud new controller show (with or without views)
  4. bud run will 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
@matthewmueller
Copy link
Contributor

matthewmueller commented Jun 24, 2022

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?

@matthewmueller matthewmueller added bug Something isn't working help wanted We'd love your help! labels Jun 24, 2022
@012e
Copy link
Contributor Author

012e commented Jun 24, 2022

Yes, 1 is just the module name.

@012e
Copy link
Contributor Author

012e commented Jun 26, 2022

My previous report was wrong so I rewrote it

@matthewmueller
Copy link
Contributor

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.

@012e
Copy link
Contributor Author

012e commented Jun 28, 2022

Are you blocked by this one @012e?

Not really, I don't need this

@dangerzone
Copy link

dangerzone commented Jul 7, 2022

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.

@jfmario
Copy link
Contributor

jfmario commented Jul 16, 2022

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.

@jfmario jfmario mentioned this issue Jul 16, 2022
@012e 012e closed this as completed Aug 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted We'd love your help!
Projects
None yet
Development

No branches or pull requests

4 participants