Add lease_seconds handling
This commit is contained in:
parent
2c9ef77e93
commit
4c55813366
|
|
@ -3,11 +3,10 @@ package main
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
//"strings"
|
|
||||||
//import "strconv"
|
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
const letterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
const letterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||||
|
|
@ -38,12 +37,12 @@ func (handler *subscriptionHandler) ServeHTTP(w http.ResponseWriter, r *http.Req
|
||||||
mode := r.Form.Get("hub.mode")
|
mode := r.Form.Get("hub.mode")
|
||||||
callback := r.Form.Get("hub.callback")
|
callback := r.Form.Get("hub.callback")
|
||||||
topic := r.Form.Get("hub.topic")
|
topic := r.Form.Get("hub.topic")
|
||||||
// leaseSecondsStr := r.Form.Get("hub.lease_seconds")
|
leaseSecondsStr := r.Form.Get("hub.lease_seconds")
|
||||||
// leaseSeconds, err := strconv.ParseInt(leaseSecondsStr, 10, 64)
|
_, err = strconv.ParseInt(leaseSecondsStr, 10, 64)
|
||||||
// if leaseSecondsStr != "" && err != nil {
|
if leaseSecondsStr != "" && err != nil {
|
||||||
// http.Error(w, "hub.lease_seconds is used, but not valid", 400)
|
http.Error(w, "hub.lease_seconds is used, but not valid", 400)
|
||||||
// return
|
return
|
||||||
// }
|
}
|
||||||
//secret := r.Form.Get("hub.secret")
|
//secret := r.Form.Get("hub.secret")
|
||||||
|
|
||||||
if mode == "subscribe" {
|
if mode == "subscribe" {
|
||||||
|
|
@ -70,6 +69,7 @@ func (handler *subscriptionHandler) ServeHTTP(w http.ResponseWriter, r *http.Req
|
||||||
q.Add("hub.mode", "subscribe")
|
q.Add("hub.mode", "subscribe")
|
||||||
q.Add("hub.topic", topicURL.String())
|
q.Add("hub.topic", topicURL.String())
|
||||||
q.Add("hub.challenge", RandStringBytes(12))
|
q.Add("hub.challenge", RandStringBytes(12))
|
||||||
|
q.Add("hub.lease_seconds", leaseSecondsStr)
|
||||||
validationURL.RawQuery = q.Encode()
|
validationURL.RawQuery = q.Encode()
|
||||||
|
|
||||||
log.Println(validationURL)
|
log.Println(validationURL)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user