via

Simple pubsub server inspired by https://patchbay.pub/
git clone https://git.ce9e.org/via.git

commit
09793099b4cc716a93929e04e6ca3c6ebadad6a5
parent
fa9177ac57d4a342286006109a3dd3c4070cb1c5
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2025-06-09 05:13
refactor: rename ok to exists for map access

Diffstat

M via.go 8 ++++----

1 files changed, 4 insertions, 4 deletions


diff --git a/via.go b/via.go

@@ -133,10 +133,10 @@ func (topic *Topic) put(data []byte, lastId int) {
  133   133 
  134   134 func getTopic(key string) *Topic {
  135   135 	mux.RLock()
  136    -1 	topic, ok := topics[key]
   -1   136 	topic, exists := topics[key]
  137   137 	mux.RUnlock()
  138   138 
  139    -1 	if !ok {
   -1   139 	if !exists {
  140   140 		topic = &Topic{
  141   141 			channels:   make(map[chan Msg]bool, 0),
  142   142 			hasHistory: hasHistory(key),
@@ -199,7 +199,7 @@ func post(w http.ResponseWriter, r *http.Request) {
  199   199 	}
  200   200 
  201   201 	mux.RLock()
  202    -1 	topic, ok := topics[r.URL.Path]
   -1   202 	topic, exists := topics[r.URL.Path]
  203   203 	mux.RUnlock()
  204   204 
  205   205 	response := make(map[string]int)
@@ -208,7 +208,7 @@ func post(w http.ResponseWriter, r *http.Request) {
  208   208 		json.NewEncoder(w).Encode(response)
  209   209 	}()
  210   210 
  211    -1 	if !ok {
   -1   211 	if !exists {
  212   212 		return
  213   213 	}
  214   214