fix format.

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
Bo-Yi Wu 2016-03-25 00:53:45 +08:00
parent dec7c1cfed
commit 88529bdb15
2 changed files with 12 additions and 12 deletions

View File

@ -1,11 +1,11 @@
package main package main
import ( import (
"net/http"
"github.com/gin-gonic/gin"
api "github.com/appleboy/gin-status-api" api "github.com/appleboy/gin-status-api"
"github.com/fvbock/endless" "github.com/fvbock/endless"
"github.com/gin-gonic/gin"
"log" "log"
"net/http"
) )
func AbortWithError(c *gin.Context, code int, message string) { func AbortWithError(c *gin.Context, code int, message string) {

View File

@ -1,9 +1,9 @@
package main package main
import( import (
apns "github.com/sideshow/apns2" apns "github.com/sideshow/apns2"
"github.com/sideshow/apns2/payload"
"github.com/sideshow/apns2/certificate" "github.com/sideshow/apns2/certificate"
"github.com/sideshow/apns2/payload"
"log" "log"
) )
@ -17,14 +17,14 @@ type RequestPushNotification struct {
Tokens []string `json:"tokens" binding:"required"` Tokens []string `json:"tokens" binding:"required"`
Platform int `json:"platform" binding:"required"` Platform int `json:"platform" binding:"required"`
Message string `json:"message" binding:"required"` Message string `json:"message" binding:"required"`
Priority string `json:"priority,omitempty"` Priority string `json:"priority,omitempty"`
// Android // Android
CollapseKey string `json:"collapse_key,omitempty"` CollapseKey string `json:"collapse_key,omitempty"`
DelayWhileIdle bool `json:"delay_while_idle,omitempty"` DelayWhileIdle bool `json:"delay_while_idle,omitempty"`
TimeToLive int `json:"time_to_live,omitempty"` TimeToLive int `json:"time_to_live,omitempty"`
// iOS // iOS
ApnsID string `json:"apns_id,omitempty"` ApnsID string `json:"apns_id,omitempty"`
Topic string `json:"topic,omitempty"` Topic string `json:"topic,omitempty"`
Badge int `json:"badge,omitempty"` Badge int `json:"badge,omitempty"`
Sound string `json:"sound,omitempty"` Sound string `json:"sound,omitempty"`
Expiry int `json:"expiry,omitempty"` Expiry int `json:"expiry,omitempty"`
@ -36,7 +36,7 @@ type RequestPushNotification struct {
func pushNotification(notification RequestPushNotification) bool { func pushNotification(notification RequestPushNotification) bool {
var ( var (
success bool success bool
) )
cert, err := certificate.FromPemFile("./key.pem", "") cert, err := certificate.FromPemFile("./key.pem", "")
@ -44,7 +44,7 @@ func pushNotification(notification RequestPushNotification) bool {
log.Println("Cert Error:", err) log.Println("Cert Error:", err)
} }
apnsClient := apns.NewClient(cert).Development() apnsClient := apns.NewClient(cert).Development()
switch notification.Platform { switch notification.Platform {
case PlatFormIos: case PlatFormIos:
@ -99,12 +99,12 @@ func pushNotificationIos(req RequestPushNotification, client *apns.Client) bool
res, err := client.Push(notification) res, err := client.Push(notification)
if err != nil { if err != nil {
log.Println("There was an error", err) log.Println("There was an error", err)
return false return false
} }
if res.Sent() { if res.Sent() {
log.Println("APNs ID:", res.ApnsID) log.Println("APNs ID:", res.ApnsID)
} }
} }