Merge pull request #4 from appleboy/version
fix #3 add server version on header.
This commit is contained in:
commit
c940f64650
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