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