Commit 54290c47 authored by Jacob Vosmaer's avatar Jacob Vosmaer

Develomentmode ended up the wrong way around

parent e845314b
......@@ -60,8 +60,8 @@ func (s *errorPageResponseWriter) Flush() {
s.WriteHeader(http.StatusOK)
}
func (st *Static) ErrorPages(enabled bool, handler http.Handler) http.Handler {
if !enabled {
func (st *Static) ErrorPagesUnless(disabled bool, handler http.Handler) http.Handler {
if disabled {
return handler
}
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
......
......@@ -27,7 +27,7 @@ func TestIfErrorPageIsPresented(t *testing.T) {
fmt.Fprint(w, "Not Found")
})
st := &Static{dir}
st.ErrorPages(true, h).ServeHTTP(w, nil)
st.ErrorPagesUnless(false, h).ServeHTTP(w, nil)
w.Flush()
testhelper.AssertResponseCode(t, w, 404)
......@@ -48,7 +48,7 @@ func TestIfErrorPassedIfNoErrorPageIsFound(t *testing.T) {
fmt.Fprint(w, errorResponse)
})
st := &Static{dir}
st.ErrorPages(true, h).ServeHTTP(w, nil)
st.ErrorPagesUnless(false, h).ServeHTTP(w, nil)
w.Flush()
testhelper.AssertResponseCode(t, w, 404)
......@@ -72,7 +72,7 @@ func TestIfErrorPageIsIgnoredInDevelopment(t *testing.T) {
fmt.Fprint(w, serverError)
})
st := &Static{dir}
st.ErrorPages(false, h).ServeHTTP(w, nil)
st.ErrorPagesUnless(true, h).ServeHTTP(w, nil)
w.Flush()
testhelper.AssertResponseCode(t, w, 500)
testhelper.AssertResponseBody(t, w, serverError)
......
......@@ -84,13 +84,13 @@ func (u *Upstream) configureRoutes() {
// To prevent anybody who knows/guesses the URL of a user-uploaded file
// from downloading it we make sure requests to /uploads/ do _not_ pass
// through static.ServeExisting.
route{"", regexp.MustCompile(`^/uploads/`), static.ErrorPages(u.DevelopmentMode, proxy)},
route{"", regexp.MustCompile(`^/uploads/`), static.ErrorPagesUnless(u.DevelopmentMode, proxy)},
// Serve static files or forward the requests
route{"", nil,
static.ServeExisting(u.URLPrefix, staticpages.CacheDisabled,
static.DeployPage(
static.ErrorPages(u.DevelopmentMode,
static.ErrorPagesUnless(u.DevelopmentMode,
proxy,
),
),
......
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