-
Notifications
You must be signed in to change notification settings - Fork 59
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 I add extra information with annotations? #21
Comments
With current approach this is not possible. We generate route information at runtime, and type/function comments are not accessible at runtime. |
One possibility is something like adding an http header that is interpreted and then removed by the yaag middleware. Not super elegant, but would do the trick. Could even have a utility function to add it with a function call or something. Still wouldn't be an annotation though. Thoughts @aniketawati? |
@cristianchaparroa - Implemented a quick possible solution here, check out examples/core/server.go for the usage. Not quite an annotation, but works fairly similarly. @aniketawati - not sure what you think of something like this, it is a bit of a stretch of the original usage, but it's kind of nice to have as a feature. This is just an MVP but I wanted to let you take a look before I did too much more. |
@BrianNewsom adding annotations in code won't be a good idea. We don't want any of this code to run in production. Every handler calling annotations package methods even when yaag is not ON, would be an overhead if you consider large loads. Better way for implementing this would be to take the source path as a parameter in Yaag init. Get a list of handler packages in yaag init. Use https://godoc.org/go/doc to generate godoc in memory for the packages. In middleware, loop through next functions, and find their package/names through reflection, and get corresponding comments through godoc. |
I have added a preliminary implementation for this in a feature branch - feature/annotations. The annotations could go into a metadata object in Spec. While processing spec client can relate ApiCall path to Metadata and generate docs. This is a generated sample -
Run example in examples/core/ to see this in action. |
I would like to add additional information to the template using some annotations over the functions handlers, something like
And handle the route
And generate something like
can I do that?
The text was updated successfully, but these errors were encountered: