diff --git a/main.go b/main.go index d49d757..e01a0d4 100644 --- a/main.go +++ b/main.go @@ -45,6 +45,7 @@ func GetMainEngine() *gin.Engine { // Global middleware r.Use(gin.Logger()) r.Use(gin.Recovery()) + r.Use(VersionMiddleware()) r.GET("/api/status", api.StatusHandler) r.POST("/api/push", pushHandler) diff --git a/notification.go b/notification.go index 4ce7744..8d579ee 100644 --- a/notification.go +++ b/notification.go @@ -4,6 +4,7 @@ import ( apns "github.com/sideshow/apns2" "github.com/sideshow/apns2/certificate" "github.com/sideshow/apns2/payload" + _ "github.com/google/go-gcm" "log" ) diff --git a/version.go b/version.go new file mode 100644 index 0000000..cfb2a59 --- /dev/null +++ b/version.go @@ -0,0 +1,22 @@ +package main + +import ( + "fmt" + "runtime" + "github.com/gin-gonic/gin" +) + +func PrintGoPushVersion() { + fmt.Printf(`GoPush %s Compiler: %s %s Copyright (C) 2016 Bo-Yi Wu, Inc.`, + Version, + runtime.Compiler, + runtime.Version()) +} + +func VersionMiddleware() gin.HandlerFunc { + // Set out header value for each response + return func(c *gin.Context) { + c.Writer.Header().Set("Server-Version", "GoPush "+Version) + c.Next() + } +}