package web import ( "os" "github.com/gin-gonic/gin" "github.com/spf13/viper" ) // InitRouter starts the router func InitRouter() { router := gin.Default() router.POST("/e/", encode) router.GET("/r/:short", redirect) router.GET("/d/:short", decode) router.GET("/i/:short", info) router.GET("/f/:short", getFile) if viper.GetBool("UseSocket") { router.RunUnix(viper.GetString("BindSocket")) os.Chmod(viper.GetString("BindSocket"), 0775) } else { router.Run(viper.GetString("BindAddress")) } }