mirror of
https://github.com/yusing/godoxy.git
synced 2026-03-28 12:22:12 +01:00
v0.5.0-rc5: check release
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
package fields
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
E "github.com/yusing/go-proxy/error"
|
||||
)
|
||||
|
||||
@@ -11,24 +9,11 @@ type Scheme string
|
||||
func NewScheme(s string) (Scheme, E.NestedError) {
|
||||
switch s {
|
||||
case "http", "https", "tcp", "udp":
|
||||
return Scheme(s), E.Nil()
|
||||
return Scheme(s), nil
|
||||
}
|
||||
return "", E.Invalid("scheme", s)
|
||||
}
|
||||
|
||||
func NewSchemeFromPort(p string) (Scheme, E.NestedError) {
|
||||
var s string
|
||||
switch {
|
||||
case strings.ContainsRune(p, ':'):
|
||||
s = "tcp"
|
||||
case strings.HasSuffix(p, "443"):
|
||||
s = "https"
|
||||
default:
|
||||
s = "http"
|
||||
}
|
||||
return Scheme(s), E.Nil()
|
||||
}
|
||||
|
||||
func (s Scheme) IsHTTP() bool { return s == "http" }
|
||||
func (s Scheme) IsHTTPS() bool { return s == "https" }
|
||||
func (s Scheme) IsTCP() bool { return s == "tcp" }
|
||||
|
||||
Reference in New Issue
Block a user