show yatwiki version in Server header

This commit is contained in:
mappu 2017-10-29 13:40:00 +13:00
parent 9687f90cf5
commit a9a6b51a3f
2 changed files with 7 additions and 2 deletions

View File

@ -9,7 +9,10 @@ SOURCES:=Makefile \
cmd $(wildcard cmd/yatwiki-server/*.go) \ cmd $(wildcard cmd/yatwiki-server/*.go) \
$(wildcard *.go) $(wildcard *.go)
GOFLAGS := -ldflags='-s -w' -gcflags='-trimpath=$(GOPATH)' -asmflags='-trimpath=$(GOPATH)' GOFLAGS:=-a \
-ldflags "-s -w -X code.ivysaur.me/yatwiki.SERVER_HEADER=YATWiki/$(VERSION)" \
-gcflags '-trimpath=$(GOPATH)' \
-asmflags '-trimpath=$(GOPATH)'
# #
# Phony targets # Phony targets

View File

@ -14,6 +14,8 @@ import (
"time" "time"
) )
var SERVER_HEADER string = "YATWiki/0.0.0-devel"
type WikiServer struct { type WikiServer struct {
db *WikiDB db *WikiDB
opts *ServerOptions opts *ServerOptions
@ -79,7 +81,7 @@ func (this *WikiServer) Close() {
} }
func (this *WikiServer) ServeHTTP(w http.ResponseWriter, r *http.Request) { func (this *WikiServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Server", "YATWiki3") w.Header().Set("Server", SERVER_HEADER)
if len(this.bans) > 0 { if len(this.bans) > 0 {
remoteIP := RemoteAddrToIPAddress(r.RemoteAddr) remoteIP := RemoteAddrToIPAddress(r.RemoteAddr)