commit 226ac136f06c0cd6f4f350ead1651f0ba5066db0
parent 12b78aea16c6edff6980323729ce4ed60e208c1b
Author: kyle <kyle@0x30.net>
Date: Sun, 7 Feb 2016 21:35:28 -0700
apnd: add some more error checking
Diffstat:
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/apnd/apnd.go b/apnd/apnd.go
@@ -50,7 +50,12 @@ func process_client(c net.Conn, h http.Client) {
// Re-marshal the payload
// Can also add "aps":{"badge":33} to set badge icon too
request_body, err := json.Marshal(notify_request.Payload)
+ if err != nil {
+ log.Printf("error marshaling payload:", err)
+ return
+ }
+ // APN documentation says this is where we request stuff from
base_url := "https://api.development.push.apple.com/3/device/"
// Loop over all devices
@@ -68,7 +73,7 @@ func process_client(c net.Conn, h http.Client) {
// Make new POST request
req, err := http.NewRequest("POST", post_url, bytes.NewBuffer(request_body))
if err != nil {
- log.Printf("error making new request", err)
+ log.Printf("error making new request:", err)
continue
}
@@ -136,6 +141,7 @@ func main() {
fd, err := l.Accept()
if err != nil {
log.Fatal("accept error:", err)
+ continue
}
go process_client(fd, client)