-
Notifications
You must be signed in to change notification settings - Fork 2
/
uri.go
60 lines (49 loc) · 987 Bytes
/
uri.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package common
type UriType int64
const (
UriTypeAuthorityAbEmpty UriType = iota
UriTypeAbsolute
UriTypeRootless
UriTypeEmpty
)
type UriHostType int64
const (
UriHostTypeNone UriHostType = iota
UriHostTypeIPv4
UriHostTypeIPv6
UriHostTypeRegName
)
type Uri struct {
Type UriType
Scheme string
Authority string
HostType UriHostType
Host string
Port int32
Path string
Query string
Fragment string
PathSegments []string
}
// func ParseUri(s string) (uri Uri, err error) {
// u, err := url.Parse(s)
// if err != nil {
// return
// }
// fmt.Println(u.Host)
// uri.Scheme = u.Scheme
// uri.Host = u.Hostname()
// portstr := u.Port()
// if portstr != "" {
// var port int64
// port, err = strconv.ParseInt(portstr, 10, 32)
// if err != nil {
// return
// }
// uri.Port = int32(port)
// }
// uri.Query = u.RawQuery
// uri.Path = u.RawPath
// uri.Fragment = u.Fragment
// return
// }