main.go 462 B

123456789101112131415161718192021222324252627282930
  1. package main
  2. import (
  3. "fmt"
  4. "github.com/gin-gonic/gin"
  5. "miads/adslib"
  6. "miads/adslib/ads_redis"
  7. )
  8. func setupRouter() *gin.Engine {
  9. r := gin.Default()
  10. r.POST("/ads", adsHandler)
  11. r.GET("/ads", adsHandler)
  12. return r
  13. }
  14. func main() {
  15. ads_redis.Setup()
  16. adslib.GetConf()
  17. if ads_redis.RedisConn.ActiveCount() == 0 {
  18. fmt.Printf("setup redis failed, no active redis")
  19. return
  20. }
  21. r := setupRouter()
  22. // Listen and Server in 0.0.0.0:8080
  23. r.Run(":8080")
  24. }