Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'workhorse/backend.go')
-rw-r--r--workhorse/backend.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/workhorse/backend.go b/workhorse/backend.go
new file mode 100644
index 00000000000..aef1214abc9
--- /dev/null
+++ b/workhorse/backend.go
@@ -0,0 +1,30 @@
+package main
+
+import (
+ "fmt"
+ "net/url"
+)
+
+func parseAuthBackend(authBackend string) (*url.URL, error) {
+ backendURL, err := url.Parse(authBackend)
+ if err != nil {
+ return nil, err
+ }
+
+ if backendURL.Host == "" {
+ backendURL, err = url.Parse("http://" + authBackend)
+ if err != nil {
+ return nil, err
+ }
+ }
+
+ if backendURL.Scheme != "http" {
+ return nil, fmt.Errorf("invalid scheme, only 'http' is allowed: %q", authBackend)
+ }
+
+ if backendURL.Host == "" {
+ return nil, fmt.Errorf("missing host in %q", authBackend)
+ }
+
+ return backendURL, nil
+}