2016-03-07 06:53:23 +02:00
|
|
|
package test
|
|
|
|
|
|
|
|
import "net/url"
|
|
|
|
|
|
|
|
type (
|
|
|
|
URL struct {
|
|
|
|
url *url.URL
|
|
|
|
query url.Values
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
func (u *URL) URL() *url.URL {
|
|
|
|
return u.url
|
|
|
|
}
|
|
|
|
|
|
|
|
func (u *URL) SetPath(path string) {
|
|
|
|
u.url.Path = path
|
|
|
|
}
|
|
|
|
|
|
|
|
func (u *URL) Path() string {
|
|
|
|
return u.url.Path
|
|
|
|
}
|
|
|
|
|
2016-03-21 22:10:20 +02:00
|
|
|
func (u *URL) QueryParam(name string) string {
|
2016-03-07 06:53:23 +02:00
|
|
|
if u.query == nil {
|
|
|
|
u.query = u.url.Query()
|
|
|
|
}
|
|
|
|
return u.query.Get(name)
|
|
|
|
}
|
|
|
|
|
2016-03-23 18:10:22 +02:00
|
|
|
func (u *URL) QueryParams() map[string][]string {
|
|
|
|
if u.query == nil {
|
|
|
|
u.query = u.url.Query()
|
|
|
|
}
|
|
|
|
return map[string][]string(u.query)
|
|
|
|
}
|
|
|
|
|
2016-03-15 17:50:43 +02:00
|
|
|
func (u *URL) QueryString() string {
|
|
|
|
return u.url.RawQuery
|
|
|
|
}
|
|
|
|
|
2016-03-07 06:53:23 +02:00
|
|
|
func (u *URL) reset(url *url.URL) {
|
|
|
|
u.url = url
|
|
|
|
}
|