mirror of
https://github.com/ZizzyDizzyMC/linx-server.git
synced 2026-01-23 02:14:33 +00:00
Add ability to set arbitrary headers
This is useful if you want to add headers for things like HTTP Strict Transport Security or HTTP Public Key Pinning.
This commit is contained in:
parent
1f3bc4bfea
commit
39bb999db6
3 changed files with 61 additions and 0 deletions
|
|
@ -52,6 +52,24 @@ func TestIndex(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestAddHeader(t *testing.T) {
|
||||
Config.addHeaders = []string{"Linx-Test: It works!"}
|
||||
|
||||
mux := setup()
|
||||
w := httptest.NewRecorder()
|
||||
|
||||
req, err := http.NewRequest("GET", "/", nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
mux.ServeHTTP(w, req)
|
||||
|
||||
if w.Header().Get("Linx-Test") != "It works!" {
|
||||
t.Fatal("Header 'Linx-Test: It works!' not found in index response")
|
||||
}
|
||||
}
|
||||
|
||||
func TestAuthKeys(t *testing.T) {
|
||||
Config.authFile = "/dev/null"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue