podhmo / apikit

api toolkit (WIP)
MIT License
0 stars 0 forks source link

plugin system (extension) #140

Closed podhmo closed 2 years ago

podhmo commented 2 years ago

refs #110

podhmo commented 2 years ago

why this feature is needed?

podhmo commented 2 years ago

in #110, I am implementing pagination, and this code need the information about the type of latestId ( latestIDType ), but the design that core generator (genchi.Generator) takes this info is not comfortable.

    g := c.New(emitter)
    return g.Generate(
        context.Background(),
        r,
        design.HTTPStatusOf,
        "", // latestId is string
    )
podhmo commented 2 years ago

instead of it, wanting something like plugin, and include this in runtime package generation.

if err := g.Generate(...); err != nil {
  return err
}

myplugin.IncludeMe(g.RuntimePkg, myplugin.Options{LatestIDType: ""})
podhmo commented 2 years ago

Currently, web/webgen/gen-chi/webruntime directory has different go.mod, so this package's requirements is simply ignored in normal use-case. (e.g. go-chi/chi), this point is also fit for plugin system (at least for apikit ) .