Compare commits
No commits in common. "85ac5fb6f2819a1872883a8bd53f5c4ef3c94931" and "4ef5b7b2dd5a5033f7224a9ead9cab66ce3bc48f" have entirely different histories.
85ac5fb6f2
...
4ef5b7b2dd
|
|
@ -50,7 +50,7 @@ func (handler *subscriptionHandler) handlePublish(w http.ResponseWriter, r *http
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, sub := range subs {
|
for _, sub := range subs {
|
||||||
log.Printf("publish: preparing post to %s\n", sub.Callback)
|
log.Printf("publish: creating post to %s\n", sub.Callback)
|
||||||
postReq, err := http.NewRequest("POST", sub.Callback, strings.NewReader(string(feedContent)))
|
postReq, err := http.NewRequest("POST", sub.Callback, strings.NewReader(string(feedContent)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("could not creating request to %s: %s", sub.Callback, err)
|
log.Printf("could not creating request to %s: %s", sub.Callback, err)
|
||||||
|
|
@ -69,13 +69,12 @@ func (handler *subscriptionHandler) handlePublish(w http.ResponseWriter, r *http
|
||||||
signature := mac.Sum(nil)
|
signature := mac.Sum(nil)
|
||||||
postReq.Header.Add("X-Hub-Signature", fmt.Sprintf("sha1=%x", signature))
|
postReq.Header.Add("X-Hub-Signature", fmt.Sprintf("sha1=%x", signature))
|
||||||
}
|
}
|
||||||
log.Printf("publish: send post to %s\n", sub.Callback)
|
|
||||||
postRes, err := client.Do(postReq)
|
postRes, err := client.Do(postReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("could not publish to %s: %s", sub.Callback, err)
|
log.Printf("could not publish to %s: %s", sub.Callback, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
log.Printf("publish: post sent to %s\n", sub.Callback)
|
log.Printf("publish: post send to %s\n", sub.Callback)
|
||||||
log.Println("Response:")
|
log.Println("Response:")
|
||||||
_ = postRes.Write(os.Stdout)
|
_ = postRes.Write(os.Stdout)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
log.SetFlags(log.Ldate | log.Ltime | log.Lshortfile)
|
log.SetFlags(log.Ltime | log.Lshortfile)
|
||||||
}
|
}
|
||||||
|
|
||||||
const letterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
const letterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||||
|
|
@ -33,7 +33,7 @@ type Stat struct {
|
||||||
func main() {
|
func main() {
|
||||||
hostPort := flag.String("http", ":80", "host and port to listen on")
|
hostPort := flag.String("http", ":80", "host and port to listen on")
|
||||||
baseURL := flag.String("baseurl", "", "baseurl that the server should response with")
|
baseURL := flag.String("baseurl", "", "baseurl that the server should response with")
|
||||||
database := flag.String("database", "localhost:9999", "database host:port")
|
database := flag.String("database", "localhost:9999", "database hostpost")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
log.Printf("Using arguments http=%s baseurl=%s database=%s", *hostPort, *baseURL, *database)
|
log.Printf("Using arguments http=%s baseurl=%s database=%s", *hostPort, *baseURL, *database)
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,7 @@ import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/davecgh/go-spew/spew"
|
_ "github.com/lib/pq"
|
||||||
"github.com/lib/pq"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type postgres struct {
|
type postgres struct {
|
||||||
|
|
@ -32,9 +31,6 @@ func (s *postgres) Subscribe(topic string, sub Subscriber) error {
|
||||||
sub.LeaseSeconds,
|
sub.LeaseSeconds,
|
||||||
sub.Secret,
|
sub.Secret,
|
||||||
)
|
)
|
||||||
if e, ok := err.(pq.Error); ok {
|
|
||||||
spew.Dump(e)
|
|
||||||
}
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user