This commit is contained in:
parent
977136d9c2
commit
41209f3ee3
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
||||
data/config.toml
|
||||
data/options.json
|
23
api/form.go
23
api/form.go
@ -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))
|
||||
}
|
||||
|
Reference in New Issue
Block a user