From 13c64896eb0eecbeab7082baf8e1ae3ca7dd6ac6 Mon Sep 17 00:00:00 2001 From: bel Date: Sat, 17 Jun 2023 09:37:51 -0600 Subject: [PATCH] k --- vicuna-tools.d/main.go | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/vicuna-tools.d/main.go b/vicuna-tools.d/main.go index 635e02f..a2e98f9 100644 --- a/vicuna-tools.d/main.go +++ b/vicuna-tools.d/main.go @@ -19,9 +19,10 @@ import ( var ( Config struct { - Port int - SessionD string - Debug bool + Port int + SessionD string + Debug bool + Semaphore sync.Mutex } //go:embed template.d/login.html @@ -231,5 +232,18 @@ func handleNotFound(w http.ResponseWriter, r *http.Request) error { } func handleAPIChatBot(w http.ResponseWriter, r *http.Request) error { + cookie, _ := ParseCookie(r) + err := r.ParseForm() + if err != nil { + return err + } + + got := r.PostForm.Get("Message") + if len(got) == 0 { + return errors.New("empty Message") + } + + Config.Semaphore.Lock() + defer Config.Semaphore.Unlock() return errors.New("not impl") }