2016-01-29 09:46:11 +02:00
|
|
|
package standard
|
|
|
|
|
|
|
|
import "net/url"
|
|
|
|
|
|
|
|
type (
|
2016-03-15 04:58:46 +02:00
|
|
|
// URL implements `engine.URL`.
|
2016-01-29 09:46:11 +02:00
|
|
|
URL struct {
|
2016-03-10 22:05:33 +02:00
|
|
|
*url.URL
|
2016-01-29 09:46:11 +02:00
|
|
|
query url.Values
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
2016-03-20 00:47:20 +02:00
|
|
|
// Path implements `engine.URL#Path` function.
|
2016-01-29 09:46:11 +02:00
|
|
|
func (u *URL) Path() string {
|
2016-03-10 22:05:33 +02:00
|
|
|
return u.URL.Path
|
2016-01-29 09:46:11 +02:00
|
|
|
}
|
|
|
|
|
2016-03-20 00:47:20 +02:00
|
|
|
// SetPath implements `engine.URL#SetPath` function.
|
2016-03-15 04:58:46 +02:00
|
|
|
func (u *URL) SetPath(path string) {
|
|
|
|
u.URL.Path = path
|
|
|
|
}
|
|
|
|
|
2016-03-21 22:10:20 +02:00
|
|
|
// QueryParam implements `engine.URL#QueryParam` function.
|
|
|
|
func (u *URL) QueryParam(name string) string {
|
2016-01-29 09:46:11 +02:00
|
|
|
if u.query == nil {
|
2016-03-10 22:05:33 +02:00
|
|
|
u.query = u.Query()
|
2016-01-29 09:46:11 +02:00
|
|
|
}
|
|
|
|
return u.query.Get(name)
|
|
|
|
}
|
2016-02-05 00:40:08 +02:00
|
|
|
|
2016-03-23 18:10:22 +02:00
|
|
|
// QueryParams implements `engine.URL#QueryParams` function.
|
|
|
|
func (u *URL) QueryParams() map[string][]string {
|
|
|
|
if u.query == nil {
|
|
|
|
u.query = u.Query()
|
|
|
|
}
|
|
|
|
return map[string][]string(u.query)
|
|
|
|
}
|
|
|
|
|
2016-03-20 00:47:20 +02:00
|
|
|
// QueryString implements `engine.URL#QueryString` function.
|
2016-03-15 17:50:43 +02:00
|
|
|
func (u *URL) QueryString() string {
|
|
|
|
return u.URL.RawQuery
|
|
|
|
}
|
|
|
|
|
2016-02-05 00:40:08 +02:00
|
|
|
func (u *URL) reset(url *url.URL) {
|
2016-03-10 22:05:33 +02:00
|
|
|
u.URL = url
|
2016-03-15 21:12:00 +02:00
|
|
|
u.query = nil
|
2016-02-05 00:40:08 +02:00
|
|
|
}
|