Created
February 18, 2018 02:52
-
-
Save rkhmelyuk/cbe08469c631b6e52ea820d6ea5d51d9 to your computer and use it in GitHub Desktop.
This file contains 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
// create router and register basic handlers | |
router := gin.New() | |
if logFile != nil { | |
router.Use(gin.LoggerWithWriter(logFile)) | |
router.Use(gin.RecoveryWithWriter(logFile)) | |
} else { | |
router.Use(gin.Logger()) | |
router.Use(gin.Recovery()) | |
} | |
router.Use(Metrics()) // now we will publish metrics for each API call | |
// add service handlers | |
router.GET("/companies", service.GetCompanies) | |
router.GET("/company/:symbol", service.GetCompany) | |
// start http server on localhost:8000 and wait for requests | |
if err := router.Run("localhost:8000"); err != nil { | |
log.Error.Fatalf("Failed to start MyService: %s", err) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment