-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.go
More file actions
50 lines (37 loc) · 1.1 KB
/
server.go
File metadata and controls
50 lines (37 loc) · 1.1 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package main
import (
"os"
"github.com/gin-gonic/gin"
"github.com/gin-contrib/static"
log "github.com/sirupsen/logrus"
routers "github.com/mazeForGit/WordlistTranslator/routers"
data "github.com/mazeForGit/WordlistTranslator/model"
)
func port() string {
port := os.Getenv("PORT")
if len(port) == 0 {
port = "8080"
}
return ":" + port
}
func main() {
log.SetFormatter(&log.JSONFormatter{})
log.SetOutput(os.Stdout)
router := gin.Default()
router.RedirectTrailingSlash = false
//pprof.Register(router)
router.LoadHTMLGlob("public/*.html")
router.Use(static.Serve("/", static.LocalFile("./public", false)))
router.GET("/", routers.Index)
router.GET("/index", routers.Index)
router.NoRoute(routers.NotFoundError)
router.GET("/500", routers.InternalServerError)
router.GET("/health", routers.HealthGET)
router.GET("/config", routers.ConfigGET)
router.POST("/config", routers.ConfigPOST)
router.PUT("/config", routers.ConfigPUT)
log.Info("Starting background process")
go model.ExecuteLongRunningTaskOnRequest()
log.Info("Starting gowebapp on port " + port())
router.Run(port())
}