func Init() {
	cfg = config.Get()
	if !cfg.IsDev() {
		gin.SetMode(gin.ReleaseMode)
	}
	router = gin.New()
	corsCfg := cors.DefaultConfig()
	corsCfg.AllowOrigins = []string{cfg.URL}
	if cfg.IsDev() {
		corsCfg.AllowOrigins = append(corsCfg.AllowOrigins, fmt.Sprintf("http://localhost:%d", cfg.Port))
	}
	corsMiddleware := cors.New(corsCfg)
	rate, _ := limiter.NewRateFromFormatted(cfg.Rate)
	rateLimitMiddleware := mgin.NewMiddleware(
		limiter.New(rls.NewStore(),
			rate,
			limiter.WithTrustForwardHeader(true)),
	)
	router.Use(
		gin.Recovery(),
		corsMiddleware,
		rateLimitMiddleware,
		RemoteIp(),
		gin.LoggerWithFormatter(RequestCLFLogger),
	)
	ginviewConfig := goview.DefaultConfig
	ginviewConfig.Root = "app/views"
	ginviewConfig.DisableCache = cfg.Env == "development"
	ginviewConfig.Extension = ".tpl.html"
	ginviewConfig.Funcs = getFuncMap()
	router.HTMLRender = ginview.New(ginviewConfig)
	registerStaticRoutes(router)
	registerFallbackRoutes(router)
	registerMainRoutes(router)
	registerAPIRoutes(router)
}
/*
Init performs everything requires to set up the application and start the web server
package web
import (
	"context"
	"fmt"
	"github.com/foolin/goview"
	"github.com/foolin/goview/supports/ginview"
	"github.com/gin-contrib/cors"
	"github.com/gin-gonic/gin"
	log "github.com/golang/glog"
	"github.com/muety/kitsquid/app/config"
	"github.com/n1try/limiter/v3"
	mgin "github.com/n1try/limiter/v3/drivers/middleware/gin"
	rls "github.com/n1try/limiter/v3/drivers/store/memory"
	"net/http"
	"os"
	"os/signal"
	"syscall"
)
var (
	cfg    *config.Config
	router *gin.Engine
)