Skip to content

Convert https variable to Gorilla ProxyHeaders

We temporary saved https flag in the context in !168 (diffs), but https variable is still being passed through a lot of calls.

We can use https://godoc.org/github.com/gorilla/handlers#ProxyHeaders instead of both these solutions.

We'll remove this flag in three steps

  • Merge !225 (merged) to log an error if https flag does not match the r.URL.Scheme
  • Test bed with using a reverse proxy see #219 (comment 281592054)
  • Completely remove the https flag from the context
Old description

The following discussion from !141 (merged) should be addressed:

  • @nick.thomas started a discussion: (+1 comment)

    I know we use this imperative style of middleware (returning true/false to indicate whether to end) elsewhere in gitlab-pages, but I wonder if we could avoid it in this case, and instead use the http.Handler style instead?

    One approach: the Middleware type would have a ServeHTTP() method and a next member. In the cases where we currently return false, we'd instead m.next.ServeHTTP(w, r) ; return. Otherwise, we'd serve the redirect and return.

    We use this pattern in workhorse and it serves us quite well. WDYT?

This is mostly a refactoring issue, I think it would make the gitlab-pages codebase easier to understand, and we could make use of more third-party implementations this way.

One example: we could start using https://godoc.org/github.com/gorilla/handlers#ProxyHeaders on just the ServeProxy route!

Edited by Jaime Martinez