Commit 2bd8da84 authored by Nick Thomas's avatar Nick Thomas

Revert "Merge branch 'webpack-dev-server' into 'master'"

This reverts commit bba7d53e, reversing
changes made to 815be1cc.
parent bba7d53e
...@@ -10,7 +10,6 @@ type Config struct { ...@@ -10,7 +10,6 @@ type Config struct {
Version string Version string
DocumentRoot string DocumentRoot string
DevelopmentMode bool DevelopmentMode bool
WebpackAddr string
Socket string Socket string
ProxyHeadersTimeout time.Duration ProxyHeadersTimeout time.Duration
APILimit uint APILimit uint
......
...@@ -19,7 +19,6 @@ import ( ...@@ -19,7 +19,6 @@ import (
"gitlab.com/gitlab-org/gitlab-workhorse/internal/staticpages" "gitlab.com/gitlab-org/gitlab-workhorse/internal/staticpages"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/terminal" "gitlab.com/gitlab-org/gitlab-workhorse/internal/terminal"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/upload" "gitlab.com/gitlab-org/gitlab-workhorse/internal/upload"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/webpack"
) )
type matcherFunc func(*http.Request) bool type matcherFunc func(*http.Request) bool
...@@ -140,18 +139,6 @@ func (u *Upstream) configureRoutes() { ...@@ -140,18 +139,6 @@ func (u *Upstream) configureRoutes() {
route("", apiPattern, proxy), route("", apiPattern, proxy),
route("", ciAPIPattern, proxy), route("", ciAPIPattern, proxy),
// In development mode, proxy /assets/webpack requests to webpack
// dev-server, otherwise serve static files from disk.
route(
"", `^/assets/webpack/`,
webpack.DevServer(u.DevelopmentMode, u.WebpackAddr,
static.ServeExisting(
u.URLPrefix,
staticpages.CacheExpireMax,
nil,
)),
),
// Serve assets // Serve assets
route( route(
"", `^/assets/`, "", `^/assets/`,
......
package webpack
import (
"fmt"
"net/http"
"net/http/httputil"
"net/url"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/helper"
)
func DevServer(enabled bool, address string, fallbackHandler http.Handler) http.Handler {
if !enabled {
return fallbackHandler
}
u, err := buildURL(address)
if err != nil {
panic(err)
}
return httputil.NewSingleHostReverseProxy(u)
}
func buildURL(address string) (*url.URL, error) {
u := helper.URLMustParse(address)
if u == nil {
return nil, fmt.Errorf("failed to parse URL in %q", address)
}
// Hope to support unix:// in the future
if u.Scheme != "tcp" {
return nil, fmt.Errorf("invalid scheme: %v", u)
}
u.Scheme = "http"
return u, nil
}
package webpack
import (
"testing"
)
func TestBuildURL(t *testing.T) {
examples := []struct {
input string
ok bool
}{
{"", false},
{"localhost:5000", false},
{"tcp://localhost:5000", true},
}
for _, ex := range examples {
u, err := buildURL(ex.input)
if ex.ok {
if err != nil {
t.Errorf("example %v: expected no error, got %v", ex, err)
}
expectedScheme := "http"
if u.Scheme != expectedScheme {
t.Errorf("example %v: expected scheme %q, got %q", ex, expectedScheme, u.Scheme)
}
} else {
if err == nil {
t.Errorf("example %v: expected error, got none", ex)
}
}
}
}
...@@ -51,7 +51,6 @@ var apiQueueLimit = flag.Uint("apiQueueLimit", 0, "Number of API requests allowe ...@@ -51,7 +51,6 @@ var apiQueueLimit = flag.Uint("apiQueueLimit", 0, "Number of API requests allowe
var apiQueueTimeout = flag.Duration("apiQueueDuration", queueing.DefaultTimeout, "Maximum queueing duration of requests") var apiQueueTimeout = flag.Duration("apiQueueDuration", queueing.DefaultTimeout, "Maximum queueing duration of requests")
var logFile = flag.String("logFile", "", "Log file to be used") var logFile = flag.String("logFile", "", "Log file to be used")
var prometheusListenAddr = flag.String("prometheusListenAddr", "", "Prometheus listening address, e.g. ':9100'") var prometheusListenAddr = flag.String("prometheusListenAddr", "", "Prometheus listening address, e.g. ':9100'")
var webpackAddr = flag.String("webpackAddr", "", "(development mode only) Network address of Webpack dev server, e.g. 'tcp://localhost:5000'")
func main() { func main() {
flag.Usage = func() { flag.Usage = func() {
...@@ -116,7 +115,6 @@ func main() { ...@@ -116,7 +115,6 @@ func main() {
Version: Version, Version: Version,
DocumentRoot: *documentRoot, DocumentRoot: *documentRoot,
DevelopmentMode: *developmentMode, DevelopmentMode: *developmentMode,
WebpackAddr: *webpackAddr,
ProxyHeadersTimeout: *proxyHeadersTimeout, ProxyHeadersTimeout: *proxyHeadersTimeout,
APILimit: *apiLimit, APILimit: *apiLimit,
APIQueueLimit: *apiQueueLimit, APIQueueLimit: *apiQueueLimit,
......
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