ignore options.
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed

This commit is contained in:
2022-09-17 22:18:21 +01:00
parent 977136d9c2
commit 41209f3ee3
3 changed files with 25 additions and 1 deletions

View File

@ -1,9 +1,12 @@
package api
import (
"io/ioutil"
"log"
"net/http"
"os"
"github.com/goccy/go-json"
"github.com/kataras/hcaptcha"
"fmt"
@ -22,6 +25,26 @@ var (
client = hcaptcha.New(secretKey) /* See `Client.FailureHandler` too. */
)
func FormCheck() {
jsonFile, err := os.Open("./data/options.json")
if err != nil {
fmt.Println(err)
}
defer jsonFile.Close()
byteValue, _ := ioutil.ReadAll(jsonFile)
var result map[string]interface{}
json.Unmarshal([]byte(byteValue), &result)
res := result["Form"]
if res == "true" {
Form()
} else {
log.Println("Forms disabled")
http.HandleFunc("/api/form", func(w http.ResponseWriter, r *http.Request) {
io.WriteString(w, "Disabled")
})
}
}
func Form() {
http.HandleFunc("/api/form", client.HandlerFunc(theActualFormCode))
}