Giter VIP home page Giter VIP logo

Comments (5)

aniketawati avatar aniketawati commented on June 11, 2024

With current approach this is not possible. We generate route information at runtime, and type/function comments are not accessible at runtime.

from yaag.

BrianNewsom avatar BrianNewsom commented on June 11, 2024

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?

from yaag.

BrianNewsom avatar BrianNewsom commented on June 11, 2024

@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.

https://github.com/betacraft/yaag/compare/master...BrianNewsom:master?name=master#diff-04c6e90faac2675aa89e2176d2eec7d8

from yaag.

aniketawati avatar aniketawati commented on June 11, 2024

@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.

from yaag.

aniketawati avatar aniketawati commented on June 11, 2024

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 -

{
  "ApiSpecs": null,
  "MetaData": [
    {
      "Path": "/",
      "Description": "This is a dummy handler",
      "Custom": null
    },
    {
      "Path": "/say_it",
      "Description": "This is a dummy post handler",
      "Custom": null
    }
  ]
}

Run example in examples/core/ to see this in action.

from yaag.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.