simpleRequest/param.go

37 lines
639 B
Go
Raw Permalink Normal View History

2022-03-13 13:24:29 +00:00
/*
2023-02-08 14:35:27 +00:00
*FileName: param.go
*Author: JJXu
*CreateTime: 2022/3/1 下午9:07
*Description:
2022-03-13 13:24:29 +00:00
*/
package simpleRequest
import (
"fmt"
"net/url"
)
type QueryParams struct {
simpleReq *SimpleRequest
}
2023-02-08 14:35:27 +00:00
// batch settings
func (s *QueryParams) Sets(data map[string]any) *QueryParams {
2022-03-13 13:24:29 +00:00
for k, v := range data {
s.simpleReq.queryParams.Set(k, fmt.Sprintf("%v", v))
}
return s
}
2023-02-08 14:35:27 +00:00
// single settings
func (s *QueryParams) Set(key string, value any) *QueryParams {
2022-03-13 13:24:29 +00:00
s.simpleReq.queryParams.Set(key, fmt.Sprintf("%v", value))
return s
}
2023-02-08 14:35:27 +00:00
// get all queryParams
2022-03-13 13:24:29 +00:00
func (s *QueryParams) Gets() *url.Values {
return &s.simpleReq.queryParams
}