transfer

package
v0.0.0-...-a9153d3 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2024 License: MIT Imports: 17 Imported by: 0

README

Tips for use transfer

Example

package main

import (
	"fmt"
	"testing"
)

type Time struct {
	SchoolYear string `json:"schoolYear"`
	Semester   string `json:"semester"`
	WeekNow    int    `json:"weekNow"`
	WeekDayNow int    `json:"weekDayNow"`
	TimeStamp  int    `json:"timeStamp"`
	Section    int    `json:"section"`
}

func main() {
	transfer.Init("appId", "appSecret",
		Endpoint("http://localhost:8080"),
	)

	data := new(Time)
	resp, body, errs := transfer.Get("gateway", "/time", "")
	code, status, err := req.EndStruct(&data)
	fmt.Println(code, status, err)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(appID, appKey string, options ...interface {
	apply()
})

Types

type Cache

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

type Request

type Request struct {
	*gorequest.SuperAgent
	ResponseData *Response
	RawData      string

	*http.Response

	url.Values
	// contains filtered or unexported fields
}

func Get

func Get(ctx context.Context, appID string, path string, param map[string]string, staffID string, options ...interface {
	apply(*Request)
}) (resp *Request)

func NewRequest

func NewRequest(ctx context.Context, from string, to string, path string, param map[string]string,
	staffID string, method string, postBody interface{}, options ...interface {
		apply(*Request)
	}) *Request

func Post

func Post(ctx context.Context, appID string, path string, param map[string]string, staffID string, postForm interface{}, options ...interface {
	apply(*Request)
}) (resp *Request)

func Put

func Put(ctx context.Context, appID string, path string, param map[string]string, staffID string, postForm interface{}, options ...interface {
	apply(*Request)
}) (resp *Request)

func (*Request) AddHeader

func (r *Request) AddHeader(key, value string) *Request

func (*Request) AttributesFromRequestBody

func (r *Request) AttributesFromRequestBody() []attribute.KeyValue

func (*Request) End

func (r *Request) End() (*Response, error)

func (*Request) EndStruct

func (r *Request) EndStruct(data interface{}) error

type Response

type Response struct {
	Cache bool        `json:"cache"`
	Data  interface{} `json:"data"`
	Error int         `json:"error"`
	Msg   string      `json:"msg"`
}

func (*Response) UnmarshalJSON

func (r *Response) UnmarshalJSON(bytes []byte) error

type ResponseError

type ResponseError struct {
	Errors   []error // 请求错误
	HttpCode int     // http错误
	Code     int     // 业务错误码
	Msg      string  // 业务错误信息
	Remark   string  // 备注
}

func (ResponseError) Error

func (r ResponseError) Error() string

type School

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

type Server

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

func (*Server) Debug

func (s *Server) Debug() *Server

type ServiceOptionFunc

type ServiceOptionFunc func(*Server)

func Debug

func Debug() ServiceOptionFunc

func Endpoint

func Endpoint(e string) ServiceOptionFunc

Jump to

Keyboard shortcuts

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