30 lines
466 B
Go
30 lines
466 B
Go
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")),
|
|
)
|
|
}
|
|
}
|