rpc_request.go 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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) BuildQueries() string {
  39. request.queries = "/?" + utils.GetUrlFormedMap(request.QueryParams)
  40. return request.queries
  41. }
  42. func (request *RpcRequest) GetQueries() string {
  43. return request.queries
  44. }
  45. func (request *RpcRequest) BuildUrl() string {
  46. return strings.ToLower(request.Scheme) + "://" + request.Domain + request.BuildQueries()
  47. }
  48. func (request *RpcRequest) GetUrl() string {
  49. return strings.ToLower(request.Scheme) + "://" + request.Domain + request.GetQueries()
  50. }
  51. func (request *RpcRequest) GetVersion() string {
  52. return request.version
  53. }
  54. func (request *RpcRequest) GetActionName() string {
  55. return request.actionName
  56. }
  57. func (request *RpcRequest) addPathParam(key, value string) {
  58. panic("not support")
  59. }
  60. func (request *RpcRequest) InitWithApiInfo(product, version, action, serviceCode, endpointType string) {
  61. request.init()
  62. request.product = product
  63. request.version = version
  64. request.actionName = action
  65. request.locationServiceCode = serviceCode
  66. request.locationEndpointType = endpointType
  67. }