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

Relax argument type of handleDeployPage

parent 208403df
...@@ -6,12 +6,12 @@ import ( ...@@ -6,12 +6,12 @@ import (
"path/filepath" "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) { return func(w http.ResponseWriter, r *http.Request) {
deployPage := filepath.Join(*documentRoot, "index.html") deployPage := filepath.Join(*documentRoot, "index.html")
data, err := ioutil.ReadFile(deployPage) data, err := ioutil.ReadFile(deployPage)
if err != nil { if err != nil {
handler(w, r) handler.ServeHTTP(w, r)
return return
} }
......
...@@ -19,9 +19,9 @@ func TestIfNoDeployPageExist(t *testing.T) { ...@@ -19,9 +19,9 @@ func TestIfNoDeployPageExist(t *testing.T) {
w := httptest.NewRecorder() w := httptest.NewRecorder()
executed := false executed := false
handleDeployPage(&dir, func(_ http.ResponseWriter, _ *http.Request) { handleDeployPage(&dir, http.HandlerFunc(func(_ http.ResponseWriter, _ *http.Request) {
executed = true executed = true
})(w, nil) }))(w, nil)
if !executed { if !executed {
t.Error("The handler should get executed") t.Error("The handler should get executed")
} }
...@@ -40,9 +40,9 @@ func TestIfDeployPageExist(t *testing.T) { ...@@ -40,9 +40,9 @@ func TestIfDeployPageExist(t *testing.T) {
w := httptest.NewRecorder() w := httptest.NewRecorder()
executed := false executed := false
handleDeployPage(&dir, func(_ http.ResponseWriter, _ *http.Request) { handleDeployPage(&dir, http.HandlerFunc(func(_ http.ResponseWriter, _ *http.Request) {
executed = true executed = true
})(w, nil) }))(w, nil)
if executed { if executed {
t.Error("The handler should not get 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