locks
parent
efe4adf129
commit
c153636e24
|
|
@ -11,6 +11,7 @@ import (
|
||||||
"mayhem-party/src/device/input/wrap"
|
"mayhem-party/src/device/input/wrap"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
"sync"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
|
@ -69,9 +70,17 @@ func (v01 *V01) listen() {
|
||||||
if v01.cfg.Feedback.Addr == "" {
|
if v01.cfg.Feedback.Addr == "" {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
mutex := &sync.RWMutex{}
|
||||||
s := &http.Server{
|
s := &http.Server{
|
||||||
Addr: v01.cfg.Feedback.Addr,
|
Addr: v01.cfg.Feedback.Addr,
|
||||||
Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
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 {
|
if r.Method == http.MethodGet {
|
||||||
r = r.WithContext(v01.ctx)
|
r = r.WithContext(v01.ctx)
|
||||||
user, ok := v01.cfg.Users[r.URL.Query().Get("user")]
|
user, ok := v01.cfg.Users[r.URL.Query().Get("user")]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue