Files
scm/main.go
T

41 lines
686 B
Go

package main
import (
"log"
"net/http"
"os"
"scm/api"
"github.com/joho/godotenv"
)
func main() {
err := godotenv.Load("./scm.conf")
if err != nil {
log.Fatal("Error loading .env file")
}
http.Handle("/", api.SpaHandler(http.FS(api.Frontend)))
http.HandleFunc("/api/certs", api.Certs)
if os.Getenv("ENABLE_TLS") == "true" {
e := http.ListenAndServeTLS(
os.Getenv("SERVER_ADDRESS")+":"+os.Getenv("SERVER_PORT"),
os.Getenv("CERT_FILE"),
os.Getenv("KEY_FILE"),
nil,
)
if e != nil {
log.Fatal(e)
}
} else {
e := http.ListenAndServe(
os.Getenv("SERVER_ADDRESS")+":"+os.Getenv("SERVER_PORT"),
nil,
)
if e != nil {
log.Fatal(e)
}
}
}