Fix everything odyssey pointed out.
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Midou36O 2022-09-18 17:44:37 +01:00
parent 65d35747fc
commit 1c2e6e3da9
Signed by: midou
GPG Key ID: 08063D5407090BC2
4 changed files with 6 additions and 9 deletions

1
.gitignore vendored
View File

@ -1,2 +1 @@
data/config.toml data/config.toml
data/options.json

View File

@ -18,12 +18,12 @@ var (
resAnn = config.OptAnn() resAnn = config.OptAnn()
) )
func CheckAnn() { func AnnCheck() {
if resAnn == "true" { if resAnn == "true" {
AnnPage() AnnPage()
Announcements() Announcements()
} else { } else {
log.Println("Announcements disabled") log.Println("[Segfautils] Announcements are disabled")
http.HandleFunc("/announcements", func(w http.ResponseWriter, r *http.Request) { http.HandleFunc("/announcements", func(w http.ResponseWriter, r *http.Request) {
http.Error(w, "Announcements are disabled.", http.StatusServiceUnavailable) http.Error(w, "Announcements are disabled.", http.StatusServiceUnavailable)
}) })
@ -61,6 +61,7 @@ func handleAnnouncements(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK) w.WriteHeader(http.StatusOK)
now := time.Now().Unix() now := time.Now().Unix()
data := map[string]interface{}{ data := map[string]interface{}{
"enabled": "true",
"title": r.FormValue("title"), "title": r.FormValue("title"),
"link": r.FormValue("link"), "link": r.FormValue("link"),
"severity": r.FormValue("severity"), "severity": r.FormValue("severity"),

View File

@ -26,13 +26,10 @@ func FormCheck() {
FormPage() FormPage()
Form() Form()
} else { } else {
log.Println("Forms disabled") log.Println("[Segfautils] Contact form is disabled")
http.HandleFunc("/form", func(w http.ResponseWriter, r *http.Request) { http.HandleFunc("/form", func(w http.ResponseWriter, r *http.Request) {
http.Error(w, "Form is disabled.", http.StatusServiceUnavailable) http.Error(w, "Form is disabled.", http.StatusServiceUnavailable)
}) })
http.HandleFunc("/api/form", func(w http.ResponseWriter, r *http.Request) {
http.Error(w, "{\"enabled\": \"false\"}", http.StatusServiceUnavailable)
})
} }
} }

View File

@ -28,7 +28,7 @@ func main() {
}) })
log.Println("[HTTP] Starting server") log.Println("[HTTP] Starting server")
api.CheckAnn() api.AnnCheck()
api.FormCheck() api.FormCheck()
http.HandleFunc("/api/", func(w http.ResponseWriter, r *http.Request) { http.HandleFunc("/api/", func(w http.ResponseWriter, r *http.Request) {