Commit 161d1243 authored by Jacob Vosmaer's avatar Jacob Vosmaer

Merge branch 'master' into raw-blob

parents 34b2309b 3bbb1be7
...@@ -2,6 +2,12 @@ ...@@ -2,6 +2,12 @@
Formerly known as 'gitlab-git-http-server'. Formerly known as 'gitlab-git-http-server'.
0.6.0
Overhauled the source code organization; no user-facing changes
(intended). The application code is now split into Go 'packages'
(modules).
0.5.4 0.5.4
Fix /api/v3/projects routing bug introduced in 0.5.2-0.5.3. Fix /api/v3/projects routing bug introduced in 0.5.2-0.5.3.
......
...@@ -60,8 +60,8 @@ func (s *errorPageResponseWriter) Flush() { ...@@ -60,8 +60,8 @@ func (s *errorPageResponseWriter) Flush() {
s.WriteHeader(http.StatusOK) s.WriteHeader(http.StatusOK)
} }
func (st *Static) ErrorPages(enabled bool, handler http.Handler) http.Handler { func (st *Static) ErrorPagesUnless(disabled bool, handler http.Handler) http.Handler {
if !enabled { if disabled {
return handler return handler
} }
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
......
...@@ -27,7 +27,7 @@ func TestIfErrorPageIsPresented(t *testing.T) { ...@@ -27,7 +27,7 @@ func TestIfErrorPageIsPresented(t *testing.T) {
fmt.Fprint(w, "Not Found") fmt.Fprint(w, "Not Found")
}) })
st := &Static{dir} st := &Static{dir}
st.ErrorPages(true, h).ServeHTTP(w, nil) st.ErrorPagesUnless(false, h).ServeHTTP(w, nil)
w.Flush() w.Flush()
testhelper.AssertResponseCode(t, w, 404) testhelper.AssertResponseCode(t, w, 404)
...@@ -48,7 +48,7 @@ func TestIfErrorPassedIfNoErrorPageIsFound(t *testing.T) { ...@@ -48,7 +48,7 @@ func TestIfErrorPassedIfNoErrorPageIsFound(t *testing.T) {
fmt.Fprint(w, errorResponse) fmt.Fprint(w, errorResponse)
}) })
st := &Static{dir} st := &Static{dir}
st.ErrorPages(true, h).ServeHTTP(w, nil) st.ErrorPagesUnless(false, h).ServeHTTP(w, nil)
w.Flush() w.Flush()
testhelper.AssertResponseCode(t, w, 404) testhelper.AssertResponseCode(t, w, 404)
...@@ -72,7 +72,7 @@ func TestIfErrorPageIsIgnoredInDevelopment(t *testing.T) { ...@@ -72,7 +72,7 @@ func TestIfErrorPageIsIgnoredInDevelopment(t *testing.T) {
fmt.Fprint(w, serverError) fmt.Fprint(w, serverError)
}) })
st := &Static{dir} st := &Static{dir}
st.ErrorPages(false, h).ServeHTTP(w, nil) st.ErrorPagesUnless(true, h).ServeHTTP(w, nil)
w.Flush() w.Flush()
testhelper.AssertResponseCode(t, w, 500) testhelper.AssertResponseCode(t, w, 500)
testhelper.AssertResponseBody(t, w, serverError) testhelper.AssertResponseBody(t, w, serverError)
......
...@@ -84,13 +84,13 @@ func (u *Upstream) configureRoutes() { ...@@ -84,13 +84,13 @@ func (u *Upstream) configureRoutes() {
// To prevent anybody who knows/guesses the URL of a user-uploaded file // 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 // from downloading it we make sure requests to /uploads/ do _not_ pass
// through static.ServeExisting. // 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 // Serve static files or forward the requests
route{"", nil, route{"", nil,
static.ServeExisting(u.URLPrefix, staticpages.CacheDisabled, static.ServeExisting(u.URLPrefix, staticpages.CacheDisabled,
static.DeployPage( static.DeployPage(
static.ErrorPages(u.DevelopmentMode, static.ErrorPagesUnless(u.DevelopmentMode,
proxy, 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