Initial refactor of settings.

Signed-off-by: Odyssey <odyssey346@disroot.org>
This commit is contained in:
Odyssey
2022-08-14 21:06:00 +02:00
parent f0a1883db9
commit 4a6b4a82a7
13 changed files with 641 additions and 59 deletions

15
main.go
View File

@@ -1,13 +1,13 @@
package main
import (
"html/template"
"io"
"log"
"net/http"
"os"
"text/template"
"github.com/ProjectSegfault/segfautils/api"
"github.com/ProjectSegfault/segfautils/config"
"github.com/ProjectSegfault/segfautils/utils"
)
@@ -21,14 +21,13 @@ var shit bool
func main() {
log.Println("[Segfautils] Starting")
utils.CheckEnv()
utils.CheckConfig()
log.Println("[HTTP] Starting server")
port := os.Getenv("SEGFAUTILS_PORT")
hcaptcha_site_key := os.Getenv("HCAPTCHA_SITE_KEY")
hcaptcha_site_key := config.HCaptchaSiteKey()
tmpl := template.Must(template.ParseFiles("static/index.html"))
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
data := StaticThingy{
Port: port,
Port: config.Port(),
}
tmpl.Execute(w, data)
})
@@ -49,6 +48,6 @@ func main() {
})
api.Form()
api.Announcements()
log.Println("[HTTP] HTTP server is now running at " + port + "!")
log.Println(http.ListenAndServe(":"+port, nil))
log.Println("[HTTP] HTTP server is now running at " + config.Port() + "!")
log.Println(http.ListenAndServe(":"+config.Port(), nil))
}