added routes package and serve in server package
This commit is contained in:
1 parent
303b9344f8
commit
547949795f
8 files changed
+74
-77
No files matched your search
@@ -0,0 +1,29 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
"github.com/gofiber/fiber/v2"
|
||||
)
|
||||
|
||||
func Serve(app *fiber.App) {
|
||||
enableTls, err := strconv.ParseBool(os.Getenv("ENABLE_TLS"))
|
||||
if err != nil {
|
||||
log.Fatalf("error read tls configuration, %v", err)
|
||||
}
|
||||
if enableTls {
|
||||
log.Fatal(
|
||||
app.ListenTLS(
|
||||
os.Getenv("HTTP_ADDRESS"),
|
||||
os.Getenv("CERT_FILE"),
|
||||
os.Getenv("KEY_FILE"),
|
||||
),
|
||||
)
|
||||
} else {
|
||||
log.Fatal(
|
||||
app.Listen(os.Getenv("HTTP_ADDRESS")),
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user