Created
February 18, 2018 02:41
-
-
Save rkhmelyuk/7dcc8107bfc52950b46ea42388af8e7b 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()) | |
} | |
// 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