-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Support placing API files in different folders #21581
Comments
This would definitely be a breaking change. A fundamental aspect of V is that you cannot create methods on structs in other modules. This is why all your api methods on the App struct must be in the same module as the file where your App struct is defined. Those api methods could be tiny wrappers that simply call functions in other modules, but the main api method definition must be in the same module. |
I understand your concerns, but we can consider other solutions to achieve file organization and management in this way. For large projects this is very important. No one wants their code directory to be a mess |
I understand your desire to organize your code in that way, but it has many disadvantages, in terms of complexity for the compiler. |
But I did this and the compiler didn't complain; I think this should be fixed. |
@spytheman |
I think this was suggested before. "Virtual submodules" or something. There was a long discussion on GitHub. |
It can be set up via v.mod. I'm personally not against this feature, but many are against due to complications. |
Can you give me an example to show me how to do it |
Is this type of encapsulated code block still too large, can it be encapsulated the same as the one mentioned above? One line is an API |
This issue is the only reason we don't build website backends and APIs with V. We use Go instead. |
@nkev V and Go have a very similar modular system. Can you please elaborate what Go allows you to do that V doesn't? |
@medvednikov Sure. The Go code from Avey777 above shows the issue well with It's very convenient to separate all the routes from main.v into a separate package, but I could never do it in vweb when I last tried last year. So from main.v I would like to call the package ![]() If this is possible with |
I see, yes it's now possible in veb using controllers: mut api_controller := &other_module.Api{
db: app.db
}
app.register_controller[Api, Context]('/api', mut api_controller)!
app.use(veb.cors[Context](cors_options)) |
Describe the feature
#21196
Use Case
If I store all api files in a single folder, as the number of apis increases, the organization and management of the files will become very confusing.
Proposed Solution
Other Information
No response
Acknowledgements
Version used
0.4.6
Environment details (OS name and version, etc.)
macos
linux
windows
Note
You can use the 👍 reaction to increase the issue's priority for developers.
Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.
The text was updated successfully, but these errors were encountered: