-
Notifications
You must be signed in to change notification settings - Fork 39
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
[Go] Update expose to allow mounting routes from imported packages #39
Conversation
|
// For external routes, we work back from the mount() call to get the package being called. Then | ||
// we find the function which defines the extra routes within the specified package | ||
|
||
routerMounts := h.findChiRouterMounts(f, routerName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is still limited to the same file as the listen call right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when checking for external calls, we no longer care about the listen. So we're just getting the package name of the mounted package and finding the file where the routes are defined. It's no longer in the main.go file w/ the listen anymore. Not sure if that answered your question
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is only run when a file has annotations though and weve found the listener. Im not sure if go allows the routes to be in a separate file, but is that working? Im not sure if your answer is clear to me, im a little confused
|
||
} | ||
|
||
return errors.Errorf("No import package found with name or alias [%s]", mount.PkgAlias) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we want to be returning errors from this plugin? Like at this point are we certain they meant to match the go chi syntax for us? If we ever supported another expose library for go would this get confusing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeh i was kind of on the fence. I didn't put as many errors in the first time around since we could technically just silently continue if we don't find what we expect. At this point though, yeh we have determined that there is a mount call to an external package, but we cannot find the package in the imports. Though if this were to happen, the go build for the project just wouldn't work either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alright yeah thats fine then i guess, can always remove it
Adds support for
router.Mount()
which allows you to import routers from other packages within your application.Updated Docs PR: https://github.com/klothoplatform/docs/pull/135
Updated Sample App PR: https://github.com/klothoplatform/GoSampleApps/pull/1/files
Standard checks