File tree Expand file tree Collapse file tree 4 files changed +14
-9
lines changed Expand file tree Collapse file tree 4 files changed +14
-9
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ tmp_dir = "tmp"
77
88[build ]
99# Just plain old shell command. You could use `make` as well.
10- cmd = " go build -ldflags=\" -X 'github.com/0xJacky/Nginx-UI/server/settings.BuildTime =$(date +%Y.%m.%d.%H%M%S )'\" -o ./tmp/main ."
10+ cmd = " go build -ldflags=\" -X 'github.com/0xJacky/Nginx-UI/server/settings.buildTime =$(date +%s )'\" -o ./tmp/main ."
1111# Binary file yields from `cmd`.
1212bin = " tmp/main"
1313# Customize binary.
Original file line number Diff line number Diff line change @@ -151,7 +151,7 @@ jobs:
151151 - name : Build
152152 run : |
153153 mkdir -p dist
154- go build -ldflags "$LD_FLAGS -X 'github.com/0xJacky/Nginx-UI/server/settings.BuildTime =$(date +%Y.%m.%d.%H%M%S )'" -o dist/nginx-ui -v main.go
154+ go build -ldflags "$LD_FLAGS -X 'github.com/0xJacky/Nginx-UI/server/settings.buildTime =$(date +%s )'" -o dist/nginx-ui -v main.go
155155
156156 - name : Archive backend artifacts
157157 uses : actions/upload-artifact@v2
Original file line number Diff line number Diff line change @@ -12,7 +12,6 @@ import (
1212 "net/http"
1313 "path"
1414 "strings"
15- "time"
1615)
1716
1817func recovery () gin.HandlerFunc {
@@ -84,13 +83,10 @@ func cacheJs() gin.HandlerFunc {
8483 return func (c * gin.Context ) {
8584 if strings .Contains (c .Request .URL .String (), "js" ) {
8685 c .Header ("Cache-Control" , "max-age: 1296000" )
87- t , _ := time .Parse ("2006.01.02.150405" , settings .BuildTime )
88- t = t .Add (- 8 * time .Hour )
89- lastModified := strings .ReplaceAll (t .Format (time .RFC1123 ), "UTC" , "GMT" )
90- if c .Request .Header .Get ("If-Modified-Since" ) == lastModified {
86+ if c .Request .Header .Get ("If-Modified-Since" ) == settings .LastModified {
9187 c .AbortWithStatus (http .StatusNotModified )
9288 }
93- c .Header ("Last-Modified" , lastModified )
89+ c .Header ("Last-Modified" , settings . LastModified )
9490 }
9591 }
9692}
Original file line number Diff line number Diff line change 11package settings
22
33import (
4+ "github.com/spf13/cast"
45 "gopkg.in/ini.v1"
56 "log"
7+ "strings"
8+ "time"
69)
710
811var Conf * ini.File
912
1013var (
11- BuildTime string
14+ buildTime string
15+ LastModified string
1216)
1317
1418type Server struct {
@@ -36,6 +40,11 @@ var sections = map[string]interface{}{
3640 "server" : ServerSettings ,
3741}
3842
43+ func init () {
44+ t := time .Unix (cast .ToInt64 (buildTime ), 0 )
45+ LastModified = strings .ReplaceAll (t .Format (time .RFC1123 ), "UTC" , "GMT" )
46+ }
47+
3948func Init (confPath string ) {
4049 ConfPath = confPath
4150 Setup ()
You can’t perform that action at this time.
0 commit comments