Giter VIP home page Giter VIP logo

Comments (3)

asim avatar asim commented on June 13, 2024

Hi,

Note: Go-web is not meant as a full solution, it's merely a lightweight wrapper around go-micro and a hack to support building http web apps. Here's a couple solutions to your problem.

  1. If you would like to use a different flag package or do your own configuration just avoid calling the Init method which parses the command line.

  2. If you would like to use the built in flags then have a look at the implementation of the Init method https://github.com/micro/go-web/blob/master/service.go#L201L250. See that it's merely appending new flags to the default App in go-micro/cmd and setting up some action. You can do the same.

app := cmd.App()

app.Flags = append(app.Flags, cli.StringFlag{
        Name:   "c",
        Usage:  "Path to config",
})

before := app.Before

app.Before = func(ctx *cli.Context) error {
        if path := ctx.String("c"); len(path) > 0 {
                // got config
                // do stuff
        }
        return before(ctx)
} 

// now create my service
webService := web.NewService()
// parse command line
webService.Init()

In future please file the issue with the related project, in this case https://github.com/micro/go-web. If this answer is satisfactory please close the issue.

from micro.

mvmaasakkers avatar mvmaasakkers commented on June 13, 2024

Thank you for your clear answer! We are currently starting converting our services to micro, and the go-web package enables us to start using it quickly. Option 1 works best for us atm.

Thanks again!

from micro.

hookover avatar hookover commented on June 13, 2024

thinks @asim

from micro.

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.