mirror of
https://github.com/Luzifer/twitch-manager.git
synced 2024-12-21 04:11:17 +00:00
Add api-call to remove last follower
This commit is contained in:
parent
0c41f447f7
commit
33480e92c6
1 changed files with 15 additions and 0 deletions
15
api.go
15
api.go
|
@ -92,10 +92,25 @@ var upgrader = websocket.Upgrader{
|
||||||
}
|
}
|
||||||
|
|
||||||
func registerAPI(r *mux.Router) {
|
func registerAPI(r *mux.Router) {
|
||||||
|
r.HandleFunc("/api/follows/clear-last", handleClearLastFollower)
|
||||||
r.HandleFunc("/api/subscribe", handleUpdateSocket)
|
r.HandleFunc("/api/subscribe", handleUpdateSocket)
|
||||||
r.HandleFunc("/api/webhook/{type}", handleWebHookPush)
|
r.HandleFunc("/api/webhook/{type}", handleWebHookPush)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func handleClearLastFollower(w http.ResponseWriter, r *http.Request) {
|
||||||
|
store.Followers.Last = nil
|
||||||
|
|
||||||
|
if err := store.Save(cfg.StoreFile); err != nil {
|
||||||
|
log.WithError(err).Error("Unable to update persistent store")
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := subscriptions.SendAllSockets(msgTypeStore, store); err != nil {
|
||||||
|
log.WithError(err).Error("Unable to send update to all sockets")
|
||||||
|
}
|
||||||
|
|
||||||
|
w.WriteHeader(http.StatusAccepted)
|
||||||
|
}
|
||||||
|
|
||||||
func handleUpdateSocket(w http.ResponseWriter, r *http.Request) {
|
func handleUpdateSocket(w http.ResponseWriter, r *http.Request) {
|
||||||
// Upgrade connection to socket
|
// Upgrade connection to socket
|
||||||
conn, err := upgrader.Upgrade(w, r, nil)
|
conn, err := upgrader.Upgrade(w, r, nil)
|
||||||
|
|
Loading…
Reference in a new issue