Commit 14cdbd60 authored by Jacob Vosmaer's avatar Jacob Vosmaer

Relax argument type of handleDeployPage

parent 208403df
......@@ -6,12 +6,12 @@ import (
"path/filepath"
)
func handleDeployPage(documentRoot *string, handler http.HandlerFunc) http.HandlerFunc {
func handleDeployPage(documentRoot *string, handler http.Handler) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
deployPage := filepath.Join(*documentRoot, "index.html")
data, err := ioutil.ReadFile(deployPage)
if err != nil {
handler(w, r)
handler.ServeHTTP(w, r)
return
}
......
......@@ -19,9 +19,9 @@ func TestIfNoDeployPageExist(t *testing.T) {
w := httptest.NewRecorder()
executed := false
handleDeployPage(&dir, func(_ http.ResponseWriter, _ *http.Request) {
handleDeployPage(&dir, http.HandlerFunc(func(_ http.ResponseWriter, _ *http.Request) {
executed = true
})(w, nil)
}))(w, nil)
if !executed {
t.Error("The handler should get executed")
}
......@@ -40,9 +40,9 @@ func TestIfDeployPageExist(t *testing.T) {
w := httptest.NewRecorder()
executed := false
handleDeployPage(&dir, func(_ http.ResponseWriter, _ *http.Request) {
handleDeployPage(&dir, http.HandlerFunc(func(_ http.ResponseWriter, _ *http.Request) {
executed = true
})(w, nil)
}))(w, nil)
if executed {
t.Error("The handler should not get executed")
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment