This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// example continued | |
// Module provided to fx | |
var Module = fx.Options( | |
fx.Provide(ProvideConfig), | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
func main() { | |
fx.New( | |
configfx.Module, | |
... | |
).Run() | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
// ProvideLogger to fx | |
func ProvideLogger() *zap.SugaredLogger { | |
logger, _ := zap.NewProduction() | |
slogger := logger.Sugar() | |
return slogger | |
} | |
func main() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package loggerfx | |
// imports | |
// ProvideLogger to fx | |
func ProvideLogger() *zap.SugaredLogger { | |
logger, _ := zap.NewProduction() | |
slogger := logger.Sugar() | |
return slogger |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
func main() { | |
fx.New( | |
configfx.Module, | |
loggerfx.Module, | |
... | |
).Run() | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
func main() { | |
fx.New( | |
... | |
fx.Provide(http.NewServeMux), | |
... | |
).Run() | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package httpfx | |
// imports | |
// Module provided to fx | |
var Module = fx.Options( | |
fx.Provide(http.NewServeMux), | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
// imports | |
func main() { | |
fx.New( | |
configfx.Module, | |
loggerfx.Module, | |
httpfx.Module, | |
fx.Invoke(httphandler.New), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package bundlefx | |
// imports | |
func registerHooks( | |
lifecycle fx.Lifecycle, | |
logger *zap.SugaredLogger, cfg *configfx.Config, mux *http.ServeMux, | |
) { | |
lifecycle.Append( | |
fx.Hook{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
// imports | |
func main() { | |
fx.New( | |
bundlefx.Module, | |
fx.Invoke(httphandler.New), | |
).Run() | |
} |