You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
728 B
39 lines
728 B
package model
|
|
|
|
import (
|
|
"net/url"
|
|
)
|
|
|
|
// Manage the HTTP GET request parameters
|
|
type GetRequest struct {
|
|
urls url.Values
|
|
}
|
|
|
|
// Initializer
|
|
func (p *GetRequest) Init() *GetRequest {
|
|
p.urls = url.Values{}
|
|
return p
|
|
}
|
|
|
|
// Initialized from another instance
|
|
func (p *GetRequest) InitFrom(reqParams *GetRequest) *GetRequest {
|
|
if reqParams != nil {
|
|
p.urls = reqParams.urls
|
|
} else {
|
|
p.urls = url.Values{}
|
|
}
|
|
return p
|
|
}
|
|
|
|
// Add URL escape property and value pair
|
|
func (p *GetRequest) AddParam(property string, value string) *GetRequest {
|
|
if property != "" && value != "" {
|
|
p.urls.Add(property, value)
|
|
}
|
|
return p
|
|
}
|
|
|
|
// Concat the property and value pair
|
|
func (p *GetRequest) BuildParams() string {
|
|
return p.urls.Encode()
|
|
}
|
|
|