csbhttp

package
v0.0.0-...-78d9b6d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 12, 2021 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

* Copyright 1999-2017 Alibaba Group Holding Ltd.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

CSB-HTTP-SDK based on GO language.

* Copyright 1999-2017 Alibaba Group Holding Ltd.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

CSB-HTTP-SDK based on GO language.

* Copyright 1999-2017 Alibaba Group Holding Ltd.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

CSB-HTTP-SDK based on GO language.

* Copyright 1999-2017 Alibaba Group Holding Ltd.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

CSB-HTTP-SDK based on GO language.

Index

Constants

View Source
const (
	CSB_SDK_VERSION = "1.1.0"

	API_NAME_KEY               = "_api_name"
	VERSION_KEY                = "_api_version"
	ACCESS_KEY                 = "_api_access_key"
	SECRET_KEY                 = "_api_secret_key"
	SIGNATURE_KEY              = "_api_signature"
	TIMESTAMP_KEY              = "_api_timestamp"
	RESTFUL_PATH_SIGNATURE_KEY = "csb_restful_path_signature_key" //TODO: fix the terrible key name!
)
View Source
const (
	JSON   = "application/json"
	BINARY = "application/octet-stream"
)

* 构造Http请求参数的struct

Variables

This section is empty.

Functions

func SetDefaultSetting

func SetDefaultSetting(setting CSBHTTPSettings)

*

定义自己的http属性的结构来覆盖默认的设置

Types

type Builder

type Builder func(map[string]HttpParams) string

type CSBHTTPSettings

type CSBHTTPSettings struct {
	ShowDebug        bool          //  "运行时是否显示调试信息"
	UserAgent        string        //  "调用CSB服务的客户端代理, 默认为 csbBroker"
	ConnectTimeout   time.Duration //  "连接超时时间"
	ReadWriteTimeout time.Duration //  "读写超时时间"

	Retries                int  // if set to -1 means will retry forever
	CareResponseHttpHeader bool // if return the response http headers
	SignPath               bool
}

* CSBHttp的基本设置结构

type HttpCallerException

type HttpCallerException struct {
	Message   string `xml:"Message"`   // CSB给出的详细错误信息
	RequestID string `xml:"RequestId"` // 用于唯一标识该次请求的UUID
	CauseErr  error  //具体的error
}

*

CSB调用异常结构

func Invoke

func Invoke(params HttpParams) (str string, rtnHeaders map[string][]string, hcError *HttpCallerException)

*

调用CSB开放出来的服务(后者CSB控制台的Open API),并放回结果

请求参数的内容根据 HttpParams 的定义进行设置

返回的结果包含: 调用fa返回结果串, 返回的httpheaders 和 异常
当处理正常时,异常为nil

func (HttpCallerException) Error

func (e HttpCallerException) Error() string

Implement interface error

type HttpParams

type HttpParams struct {
	// contains filtered or unexported fields
}

func NewHttpParams

func NewHttpParams(reqUrl string) *HttpParams

func (*HttpParams) AddHeader

func (hp *HttpParams) AddHeader(key string, value string) *HttpParams

func (*HttpParams) AddParam

func (hp *HttpParams) AddParam(key string, value string) *HttpParams

func (*HttpParams) Print

func (hp *HttpParams) Print()

*

打印设置的参数值

func (*HttpParams) SetAK

func (hp *HttpParams) SetAK(ak string) *HttpParams

func (*HttpParams) SetApi

func (hp *HttpParams) SetApi(api string) *HttpParams

func (*HttpParams) SetContentBody

func (hp *HttpParams) SetContentBody(jsonStr string, byteArr []byte) error

func (*HttpParams) SetMethod

func (hp *HttpParams) SetMethod(method string) *HttpParams

func (*HttpParams) SetRequest

func (hp *HttpParams) SetRequest(reqUrl string) *HttpParams

func (*HttpParams) SetSK

func (hp *HttpParams) SetSK(sk string) *HttpParams

func (*HttpParams) SetVersion

func (hp *HttpParams) SetVersion(version string) *HttpParams

func (*HttpParams) Validate

func (hp *HttpParams) Validate() *HttpCallerException

*

校验设置的请求参数项是否有效

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL