package requests import ( "fmt" "golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/utils" "io" "strings" ) type RpcRequest struct { *baseRequest } func (request *RpcRequest) init() { request.baseRequest = defaultBaseRequest() request.Method = POST } func (request *RpcRequest) BuildUrl() string { url := fmt.Sprintf("%s://%s", strings.ToLower(request.Scheme), request.Domain) if len(request.Port) > 0 { url = fmt.Sprintf("%s:%s", url, request.Port) } return url + request.BuildQueries() } func (request *RpcRequest) GetStyle() string { return RPC } func (request *RpcRequest) BuildQueries() string { path := strings.TrimLeft(strings.TrimSpace(request.GetActionName()), "/") request.queries = "/" + path + "?" + utils.GetUrlFormedMap(request.QueryParams) return request.queries } func (request *RpcRequest) GetActionName() string { return request.actionName } func (request *RpcRequest) InitWithApiInfo(domain, version, urlPath string) { request.init() request.SetDomain(domain) request.version = version request.actionName = urlPath } func (request *RpcRequest) GetBodyReader() io.Reader { if request.FormParams != nil && len(request.FormParams) > 0 { formString := utils.GetUrlFormedMap(request.FormParams) return strings.NewReader(formString) } else { return strings.NewReader("") } }