-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.go
39 lines (34 loc) · 1 KB
/
init.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
34
35
36
37
38
39
package main
import (
"os"
"strconv"
"github.com/PacodiazDG/Backend-blog/api/router"
"github.com/PacodiazDG/Backend-blog/components/configinit"
"github.com/PacodiazDG/Backend-blog/components/validation"
Middlewares "github.com/PacodiazDG/Backend-blog/middlewares"
"github.com/fatih/color"
"github.com/gin-gonic/gin"
)
func main() {
configinit.Conf()
lisent := os.Getenv("HostandPort")
if lisent == "" {
lisent = ":8080"
}
PemFile := os.Getenv("PemFile")
KeyFile := os.Getenv("KeyFile")
Server := gin.New()
Server.Use(Middlewares.GlobalHeader)
router.BackendRouter(Server)
println(lisent)
if validation.FileExists(PemFile) && validation.FileExists(KeyFile) {
Server.RunTLS(lisent, PemFile, KeyFile)
} else {
color.Red("[Error] Files Not found \n Status of PemFile: " +
strconv.FormatBool(validation.FileExists(PemFile)) +
"\n Status of KeyFile: " +
strconv.FormatBool(validation.FileExists(KeyFile)))
color.Yellow("[Warning] The server is working without SSL")
Server.Run(lisent)
}
}