You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
807 B
39 lines
807 B
package main
|
|
|
|
import (
|
|
"net/http"
|
|
"log"
|
|
"os"
|
|
)
|
|
|
|
|
|
// func init() {
|
|
// // Loads values from .env into the system
|
|
// if err := godotenv.Load(); err != nil {
|
|
// log.Println("No .env file found")
|
|
// }
|
|
// }
|
|
|
|
func main() {
|
|
var err error
|
|
db, err = connectDB();
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
defer db.Close()
|
|
|
|
// Get listen address and port
|
|
addr, exists := os.LookupEnv("LISTEN")
|
|
checkExists(exists, "Couldn't find listen address")
|
|
port, exists := os.LookupEnv("PORT")
|
|
checkExists(exists, "Couldn't find port")
|
|
|
|
// Handle hooks
|
|
http.HandleFunc("/hook/", hookHandler)
|
|
http.HandleFunc("/", index)
|
|
http.Handle("/css/", http.StripPrefix("/css/", http.FileServer(http.Dir("html/css"))))
|
|
|
|
// Start the server
|
|
log.Println("Starting server")
|
|
log.Fatal(http.ListenAndServe(addr+":"+port, nil))
|
|
}
|