1
0
Fork 0
mirror of https://github.com/binwiederhier/ntfy.git synced 2025-06-12 15:43:23 +02:00

Subscribe endpoint consolidation; same behavior for all endpoints; keepalive

This commit is contained in:
Philipp Heckel 2021-10-27 14:56:17 -04:00
parent b72afb1695
commit a38aca47bd
8 changed files with 154 additions and 93 deletions
server

View file

@ -21,15 +21,10 @@ type topic struct {
mu sync.Mutex
}
// message represents a message published to a topic
type message struct {
Time int64 `json:"time"`
Message string `json:"message"`
}
// subscriber is a function that is called for every new message on a topic
type subscriber func(msg *message) error
// newTopic creates a new topic
func newTopic(id string) *topic {
ctx, cancel := context.WithCancel(context.Background())
return &topic{