diff options
| author | Chris Lu <chrislusf@users.noreply.github.com> | 2019-11-11 22:48:43 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-11-11 22:48:43 -0800 |
| commit | 5d61b67e62deabd538b8e6e5374aa5883db02fe2 (patch) | |
| tree | 616583cdfdd2803465345fee4ee4cdbcba5f72aa /weed/util/parse.go | |
| parent | ee90236a972acea8722dccfa1b04926d551fc82d (diff) | |
| parent | 46755ea1e1e4d79e4c0368aa7fcb17ee8aa812cc (diff) | |
| download | seaweedfs-5d61b67e62deabd538b8e6e5374aa5883db02fe2.tar.xz seaweedfs-5d61b67e62deabd538b8e6e5374aa5883db02fe2.zip | |
Merge pull request #1115 from iliul/enhanced-master-logic
fix master maintenance logic
Diffstat (limited to 'weed/util/parse.go')
| -rw-r--r-- | weed/util/parse.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/weed/util/parse.go b/weed/util/parse.go index 0a8317c19..6593d43b6 100644 --- a/weed/util/parse.go +++ b/weed/util/parse.go @@ -1,7 +1,9 @@ package util import ( + "net/url" "strconv" + "strings" ) func ParseInt(text string, defaultValue int) int { @@ -24,3 +26,22 @@ func ParseUint64(text string, defaultValue uint64) uint64 { } return count } + +func ParseFilerUrl(entryPath string) (filerServer string, filerPort int64, path string, err error) { + if !strings.HasPrefix(entryPath, "http://") && !strings.HasPrefix(entryPath, "https://") { + entryPath = "http://" + entryPath + } + + var u *url.URL + u, err = url.Parse(entryPath) + if err != nil { + return + } + filerServer = u.Hostname() + portString := u.Port() + if portString != "" { + filerPort, err = strconv.ParseInt(portString, 10, 32) + } + path = u.Path + return +} |
