fix #3 add server version on header.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
parent
88529bdb15
commit
18167e643c
1
main.go
1
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)
|
||||
|
|
|
@ -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"
|
||||
)
|
||||
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue