rpc_request.go 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * Licensed under the Apache License, Version 2.0 (the "License");
  3. * you may not use this file except in compliance with the License.
  4. * You may obtain a copy of the License at
  5. *
  6. * http://www.apache.org/licenses/LICENSE-2.0
  7. *
  8. * Unless required by applicable law or agreed to in writing, software
  9. * distributed under the License is distributed on an "AS IS" BASIS,
  10. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. * See the License for the specific language governing permissions and
  12. * limitations under the License.
  13. */
  14. package requests
  15. import (
  16. "github.com/aliyun/alibaba-cloud-sdk-go/sdk/utils"
  17. "io"
  18. "strings"
  19. )
  20. type RpcRequest struct {
  21. *baseRequest
  22. }
  23. func (request *RpcRequest) init() {
  24. request.baseRequest = defaultBaseRequest()
  25. request.Method = POST
  26. }
  27. func (*RpcRequest) GetStyle() string {
  28. return RPC
  29. }
  30. func (request *RpcRequest) GetBodyReader() io.Reader {
  31. if request.FormParams != nil && len(request.FormParams) > 0 {
  32. formString := utils.GetUrlFormedMap(request.FormParams)
  33. return strings.NewReader(formString)
  34. } else {
  35. return strings.NewReader("")
  36. }
  37. }
  38. func (request *RpcRequest) GetQueries() string {
  39. if request.queries == "" {
  40. request.queries = "/?" + utils.GetUrlFormedMap(request.QueryParams)
  41. }
  42. return request.queries
  43. }
  44. func (request *RpcRequest) GetUrl() string {
  45. return strings.ToLower(request.Scheme) + "://" + request.Domain + ":" + request.Port + request.GetQueries()
  46. }
  47. func (request *RpcRequest) GetVersion() string {
  48. return request.version
  49. }
  50. func (request *RpcRequest) GetActionName() string {
  51. return request.actionName
  52. }
  53. func (request *RpcRequest) addPathParam(key, value string) {
  54. panic("not support")
  55. }
  56. func (request *RpcRequest) InitWithApiInfo(product, version, action, serviceCode, endpointType string) {
  57. request.init()
  58. request.product = product
  59. request.version = version
  60. request.actionName = action
  61. request.locationServiceCode = serviceCode
  62. request.locationEndpointType = endpointType
  63. }