-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
33 lines (26 loc) · 915 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package main
import (
"github.com/gin-gonic/contrib/static"
"github.com/gin-gonic/gin"
x "github.com/shivam1608/httpshot/api"
"github.com/shivam1608/httpshot/util"
)
var PORT string
var ENVIROMENT string
func loadConfig() {
PORT = util.GetEnv("PORT", "3000")
ENVIROMENT = util.GetEnv("ENVIROMENT", "dev")
}
func main() {
loadConfig() // Loading Config Data
if ENVIROMENT == "dev" {
gin.SetMode(gin.DebugMode)
} else {
gin.SetMode(gin.ReleaseMode)
}
router := gin.Default() // Create a router
router.Use(static.Serve("/", static.LocalFile("./public", true))) // Serving Homepage
api := router.Group("/api") // Creating API Group
x.RegisterRoutes(api) // Registering API Routes
router.Run(":" + PORT) // Listening to PORT
}