Log load and save
This commit is contained in:
parent
e62711b74a
commit
7e833dbca3
|
|
@ -108,6 +108,7 @@ func (handler *subscriptionHandler) handleUnsubscription(w http.ResponseWriter,
|
||||||
validationURL.RawQuery = q.Encode()
|
validationURL.RawQuery = q.Encode()
|
||||||
if validateURL(validationURL.String(), ourChallenge) {
|
if validateURL(validationURL.String(), ourChallenge) {
|
||||||
subs = append(subs[:i], subs[i+1:]...)
|
subs = append(subs[:i], subs[i+1:]...)
|
||||||
|
log.Println(handler.save())
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -205,11 +206,12 @@ func validateURL(url, challenge string) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (handler *subscriptionHandler) addSubscriberCallback(topic string, subscriber Subscriber) {
|
func (handler *subscriptionHandler) addSubscriberCallback(topic string, subscriber Subscriber) {
|
||||||
defer handler.save()
|
|
||||||
if subs, e := handler.Subscribers[topic]; e {
|
if subs, e := handler.Subscribers[topic]; e {
|
||||||
for i, sub := range subs {
|
for i, sub := range subs {
|
||||||
if sub.Callback == subscriber.Callback {
|
if sub.Callback == subscriber.Callback {
|
||||||
handler.Subscribers[topic][i] = subscriber
|
handler.Subscribers[topic][i] = subscriber
|
||||||
|
log.Println(handler.save())
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -289,7 +291,7 @@ func (handler *subscriptionHandler) save() error {
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
handler := &subscriptionHandler{}
|
handler := &subscriptionHandler{}
|
||||||
handler.load()
|
log.Println(handler.load())
|
||||||
http.Handle("/", handler)
|
http.Handle("/", handler)
|
||||||
log.Fatal(http.ListenAndServe(":80", nil))
|
log.Fatal(http.ListenAndServe(":80", nil))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user