added backend
This commit is contained in:
1 parent
9842ccee3d
commit
40bcd02c36
10 files changed
+340
-75
No files matched your search
@@ -0,0 +1,35 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"dshbrd/api"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"github.com/joho/godotenv"
|
||||
)
|
||||
|
||||
func main() {
|
||||
err := godotenv.Load(".env")
|
||||
if err != nil {
|
||||
log.Fatal("error loading .env file")
|
||||
}
|
||||
|
||||
http.Handle("/", api.SpaHandler(os.Getenv("ROOT_DIRECTORY"), os.Getenv("INDEX_FILE")))
|
||||
http.HandleFunc("/api/services", api.Services)
|
||||
http.HandleFunc("/api/services/add", api.AddService)
|
||||
|
||||
if os.Getenv("ENABLE_TLS") == "true" {
|
||||
http.ListenAndServeTLS(
|
||||
os.Getenv("SERVER_ADDRESS")+":"+os.Getenv("SERVER_PORT"),
|
||||
os.Getenv("CERT_FILE"),
|
||||
os.Getenv("KEY_FILE"),
|
||||
nil,
|
||||
)
|
||||
} else {
|
||||
http.ListenAndServe(
|
||||
os.Getenv("SERVER_ADDRESS")+":"+os.Getenv("SERVER_PORT"),
|
||||
nil,
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user