more refactor
This commit is contained in:
1 parent
6413447f96
commit
3b78352109
16 files changed
+345
-219
No files matched your search
@@ -1,42 +1,12 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"scm/api"
|
||||
|
||||
"github.com/joho/godotenv"
|
||||
"scm/server"
|
||||
"scm/utils"
|
||||
)
|
||||
|
||||
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)
|
||||
http.HandleFunc("/api/certs/create", api.CreateCert)
|
||||
http.HandleFunc("/api/certs/delete", api.DeleteCert)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
utils.LoadEnv()
|
||||
server.Configure()
|
||||
server.Run()
|
||||
}
|
||||
Reference in new issue
Block a user