package main

import (
	"fmt"
	"github.com/gin-gonic/gin"
	"miads/adslib"
	"miads/adslib/ads_redis"
)

func setupRouter() *gin.Engine {
	r := gin.Default()

	r.POST("/ads", adsHandler)
	r.GET("/ads", adsHandler)
	return r
}

func main() {
	ads_redis.Setup()
	adslib.GetConf()

	if ads_redis.RedisConn.ActiveCount() == 0 {
		fmt.Printf("setup redis failed, no active redis")
		return
	}

	r := setupRouter()
	// Listen and Server in 0.0.0.0:8080
	r.Run(":8080")
}