Open podhmo opened 2 years ago
take the component as arguments, instead of something this.
// provide component in runtime func Hello(getProvider func(*http.Request) (*http.Request, Provider, error)) func(http.ResponseWriter, *http.Request) { return func(w http.ResponseWriter, req *http.Request) { req, provider, err := getProvider(req) if err != nil { runtime.HandleResult(w, req, nil, err) return } var ctx context.Context = req.Context() var logger *log.Logger { logger = provider.Logger() } result, err := action.Hello(ctx, logger) runtime.HandleResult(w, req, result, err) } }
only this
// provide component in setup phase func Hello(logger *log.Logger) func(http.ResponseWriter, *http.Request) { return func(w http.ResponseWriter, req *http.Request) { ctx := req.Context() result, err := action.Hello(ctx, logger) runtime.HandleResult(w, req, result, err) } }
marked by tracker?
tracker.AsStatic(func(logger *log.Logger) {}) // or tracker.AsStatic(&Logger{})
💠not a good name, all of this issue.
take the component as arguments, instead of something this.
only this