mirror of
https://github.com/yusing/godoxy.git
synced 2026-03-22 17:40:28 +01:00
preparing for v0.5
This commit is contained in:
20
src/proxy/fields/host.go
Normal file
20
src/proxy/fields/host.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package fields
|
||||
|
||||
import (
|
||||
E "github.com/yusing/go-proxy/error"
|
||||
F "github.com/yusing/go-proxy/utils/functional"
|
||||
)
|
||||
|
||||
type Host struct{ F.Stringable }
|
||||
type Subdomain = Alias
|
||||
|
||||
func NewHost(s string) (Host, E.NestedError) {
|
||||
return Host{F.NewStringable(s)}, E.Nil()
|
||||
}
|
||||
|
||||
func (h Host) Subdomain() (*Subdomain, E.NestedError) {
|
||||
if i := h.IndexRune(':'); i != -1 {
|
||||
return &Subdomain{h.SubStr(0, i)}, E.Nil()
|
||||
}
|
||||
return nil, E.Invalid("host", h)
|
||||
}
|
||||
Reference in New Issue
Block a user