dupco

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode added in v1.0.1

func Decode(data, secret []byte) ([]byte, error)

Decode : decode data

func DecodePushData added in v1.1.3

func DecodePushData(data, secret []byte) ([]byte, error)

DecodePushData : decode push data

func DecodeRequestData added in v1.1.1

func DecodeRequestData(req *http.Request, secret []byte) ([]byte, error)

DecodeDataFromRequest: get decode data from http.Request

Types

type Client

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

Client is a dupco representing a instance

func NewBaseClient added in v1.0.7

func NewBaseClient(clientId, secretKey, secretVal string) *Client

NewBaseClient: create and return a new dupco

clientId identify of dupco secretKey key of secret secretVal value of secret

func NewDataClient added in v1.0.7

func NewDataClient(clientId, secretKey, secretVal string) *Client

NewDataClient: create and return a new dupco

clientId identify of dupco secretKey key of secret secretVal value of secret

func (*Client) Call

func (p *Client) Call(apiId string, data []byte) (res Response)

Call: call remote function

Response response from remote server response if valid if error is nil

func (*Client) EnableTestMode

func (p *Client) EnableTestMode()

EnableTestMode: enable test mode

Warnning: if you call method with test mode ,the reponse will be different. So DO NOT use it on production mode

type Response

type Response struct {
	// Code response code
	//
	// |code  | describe                        |
	// |------|---------------------------------|
	// |0     | success                         |
	// |10000 | IP not in whitelist             |
	// |10001 | Request path error              |
	// |10002 | Internal server error           |
	// |10100 | Param cilent_id required        |
	// |10101 | Param client_id not found       |
	// |10102 | This service is not activated   |
	// |10200 | Secret key required             |
	// |10201 | Secret not found                |
	// |10202 | Decode failed                   |
	// |10203 | Get request body failed         |
	// |10300 | Service not found               |
	// |10999 | Other error                     |
	//
	// code 0 means success, others means errors
	Code int `json:"code"`

	// Msg the message of response
	// if code not 0, the msg will tell you the reason
	Msg string `json:"msg,omitempty"`

	// Data the data of response, The responses are different depending on the service
	// if code not 0, the data will be nil
	Data interface{} `json:"data,omitempty"`
}

Response is the response of request

Jump to

Keyboard shortcuts

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