Skip to content
This repository was archived by the owner on Oct 5, 2025. It is now read-only.

Commit 1b51ec1

Browse files
committed
Remove response headers
1 parent ebe254f commit 1b51ec1

File tree

3 files changed

+5
-51
lines changed

3 files changed

+5
-51
lines changed

README.md

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ GSS (Go serve SPA) is a containerized web server for single-page applications wr
77
- Optimized for single-page apps.
88
- Automatically serves pre-compressed brotli and gzip files if available.
99
- Sensible default cache configuration.
10-
- Configurable response headers.
1110
- Optional out-of-the-box metrics.
1211
- Deployable as a container.
1312
- Lightweight.
@@ -100,26 +99,6 @@ Configures the port where metrics, if enabled, will be available. `8081` by defa
10099
> metricsPort: 3001
101100
> ```
102101
103-
### Response headers: `headers`
104-
105-
##### string: {string: string}
106-
107-
Headers to add to the response. `Cache-Control`, `Content-Encoding`, `Content-Type`, and `Vary` are automatically set.
108-
109-
> Example:
110-
>
111-
> ```yaml
112-
> # gss.yaml
113-
>
114-
> headers:
115-
> Content-Security-Policy: "default-src 'self'; connect-src 'self'"
116-
> Referrer-Policy: "strict-origin-when-cross-origin"
117-
> Strict-Transport-Security: "max-age=63072000; includeSubDomains; preload"
118-
> X-Content-Type-Options: "nosniff"
119-
> X-Frame-Options: "SAMEORIGIN"
120-
> X-XSS-Protection: "1; mode=block"
121-
> ```
122-
123102
### Metrics collection: `metrics`
124103
125104
##### string: boolean

gss.go

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,16 @@ func setUpLogger() {
4848
}
4949

5050
type config struct {
51-
FilesPort int `yaml:"filesPort,omitempty"`
52-
MetricsPort int `yaml:"metricsPort,omitempty"`
53-
ResponseHeaders map[string]string `yaml:"headers,omitempty"`
54-
MetricsEnabled bool `yaml:"metrics,omitempty"`
51+
FilesPort int `yaml:"filesPort,omitempty"`
52+
MetricsPort int `yaml:"metricsPort,omitempty"`
53+
MetricsEnabled bool `yaml:"metrics,omitempty"`
5554
}
5655

5756
func newConfig() *config {
5857
return &config{
5958
// Default values
60-
FilesPort: 8080,
61-
MetricsPort: 8081,
62-
ResponseHeaders: map[string]string{
63-
"Server": "GSS",
64-
},
59+
FilesPort: 8080,
60+
MetricsPort: 8081,
6561
MetricsEnabled: false,
6662
}
6763
}
@@ -122,10 +118,6 @@ func (f *fileServer) setHeaders(h http.Handler) http.HandlerFunc {
122118
return func(w http.ResponseWriter, r *http.Request) {
123119
w.Header().Set("Vary", "Accept-Encoding")
124120

125-
for k, v := range f.Config.ResponseHeaders {
126-
w.Header().Set(k, v)
127-
}
128-
129121
h.ServeHTTP(w, r)
130122
}
131123
}

gss_test.go

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,6 @@ import (
1111
func TestGSS(t *testing.T) {
1212
metrics := registerMetrics()
1313

14-
t.Run("uses the provided headers", func(t *testing.T) {
15-
t.Parallel()
16-
17-
cfg := &config{
18-
ResponseHeaders: map[string]string{
19-
"X-Test": "test",
20-
},
21-
}
22-
fileServer := newFileServer(cfg, metrics).init()
23-
w := httptest.NewRecorder()
24-
r := httptest.NewRequest(http.MethodGet, "/", nil)
25-
26-
fileServer.Server.Handler.ServeHTTP(w, r)
27-
28-
assert.Equal(t, "test", w.Header().Get("X-Test"))
29-
})
30-
3114
t.Run("redirects index correctly", func(t *testing.T) {
3215
t.Parallel()
3316

0 commit comments

Comments
 (0)