master
bel 2023-03-25 23:04:00 -06:00
parent efe4adf129
commit c153636e24
1 changed files with 9 additions and 0 deletions

View File

@ -11,6 +11,7 @@ import (
"mayhem-party/src/device/input/wrap"
"net/http"
"os"
"sync"
"syscall"
"time"
@ -69,9 +70,17 @@ func (v01 *V01) listen() {
if v01.cfg.Feedback.Addr == "" {
return
}
mutex := &sync.RWMutex{}
s := &http.Server{
Addr: v01.cfg.Feedback.Addr,
Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.Method == http.MethodGet {
mutex.RLock()
defer mutex.RUnlock()
} else {
mutex.Lock()
defer mutex.Unlock()
}
if r.Method == http.MethodGet {
r = r.WithContext(v01.ctx)
user, ok := v01.cfg.Users[r.URL.Query().Get("user")]