1
0
mirror of https://github.com/labstack/echo.git synced 2024-12-22 20:06:21 +02:00
echo/engine/standard/url.go

48 lines
914 B
Go
Raw Normal View History

package standard
import "net/url"
type (
// URL implements `engine.URL`.
URL struct {
*url.URL
query url.Values
}
)
// Path implements `engine.URL#Path` function.
func (u *URL) Path() string {
return u.URL.EscapedPath()
}
// SetPath implements `engine.URL#SetPath` function.
func (u *URL) SetPath(path string) {
u.URL.Path = path
}
// QueryParam implements `engine.URL#QueryParam` function.
func (u *URL) QueryParam(name string) string {
if u.query == nil {
u.query = u.Query()
}
return u.query.Get(name)
}
// 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)
}
// QueryString implements `engine.URL#QueryString` function.
func (u *URL) QueryString() string {
return u.URL.RawQuery
}
func (u *URL) reset(url *url.URL) {
u.URL = url
2016-03-15 21:12:00 +02:00
u.query = nil
}