flip signature, disabled by default

This commit is contained in:
Umputun
2021-04-13 14:08:15 -05:00
parent 510b29c3ec
commit 6dcc2fa719
4 changed files with 37 additions and 36 deletions

View File

@@ -24,18 +24,18 @@ import (
// Http is a proxy server for both http and https
type Http struct { // nolint golint
Matcher
Address string
AssetsLocation string
AssetsWebRoot string
MaxBodySize int64
GzEnabled bool
ProxyHeaders []string
SSLConfig SSLConfig
Version string
AccessLog io.Writer
StdOutEnabled bool
DisableSignature bool
Timeouts Timeouts
Address string
AssetsLocation string
AssetsWebRoot string
MaxBodySize int64
GzEnabled bool
ProxyHeaders []string
SSLConfig SSLConfig
Version string
AccessLog io.Writer
StdOutEnabled bool
Signature bool
Timeouts Timeouts
}
// Matcher source info (server and route) to the destination url
@@ -228,14 +228,14 @@ func (h *Http) gzipHandler() func(next http.Handler) http.Handler {
}
func (h *Http) signatureHandler() func(next http.Handler) http.Handler {
if h.DisableSignature {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
next.ServeHTTP(w, r)
})
}
if h.Signature {
return R.AppInfo("reproxy", "umputun", h.Version)
}
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
next.ServeHTTP(w, r)
})
}
return R.AppInfo("reproxy", "umputun", h.Version)
}
func (h *Http) accessLogHandler(wr io.Writer) func(next http.Handler) http.Handler {

View File

@@ -21,7 +21,7 @@ import (
func TestHttp_Do(t *testing.T) {
port := rand.Intn(10000) + 40000
h := Http{Timeouts: Timeouts{ResponseHeader: 200 * time.Millisecond}, Address: fmt.Sprintf("127.0.0.1:%d", port),
AccessLog: io.Discard}
AccessLog: io.Discard, Signature: true}
ctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)
defer cancel()
@@ -94,7 +94,7 @@ func TestHttp_Do(t *testing.T) {
func TestHttp_DoWithAssets(t *testing.T) {
port := rand.Intn(10000) + 40000
h := Http{Timeouts: Timeouts{ResponseHeader: 200 * time.Millisecond}, Address: fmt.Sprintf("127.0.0.1:%d", port),
AccessLog: io.Discard, AssetsWebRoot: "/static", AssetsLocation: "testdata", DisableSignature: true}
AccessLog: io.Discard, AssetsWebRoot: "/static", AssetsLocation: "testdata"}
ctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)
defer cancel()