httpcommon

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: May 25, 2022 License: LGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TOKEN_EXPIRES  = -20 // token 过期
	RESPONSE_ERROR = -10 // 请求错误
	RESPONSE_OK    = 0   // 请求成功
)

Variables

View Source
var Mux map[string]func(w http.ResponseWriter, r *http.Request)

Functions

func AddRolter

func AddRolter(r string, f func(http.ResponseWriter, *http.Request))

添加路由

func Cors added in v1.0.1

func Cors(w http.ResponseWriter)

func DefaultQuery

func DefaultQuery(url *url.URL, key, defaultValue string) string

func InitHttpServer

func InitHttpServer(HttpListenPort, HttpsListenPort, CertFile, KeyFile string, backend bool)

func ParseJsonBody

func ParseJsonBody(w http.ResponseWriter, r *http.Request, v interface{}) error

func QueryNum

func QueryNum(url *url.URL, key string) (int, error)

func SendHttpGet

func SendHttpGet(url string, hk, hv []string) (string, error)

func SendHttpGetHeader added in v1.0.4

func SendHttpGetHeader(url string, hk, hv []string) (string, http.Header, error)

返回数据和头的get请求

func SendHttpGetQ

func SendHttpGetQ(url string, hk, hv []string) (*goquery.Document, error)

func SendHttpPost

func SendHttpPost(url string, in interface{}) (string, error)

func WriteError

func WriteError(w http.ResponseWriter, r *http.Request, rd interface{})

Types

type MyHandler

type MyHandler struct {
}

func (*MyHandler) ServeHTTP

func (lh *MyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type ResponDData

type ResponDData struct {
	Time string `json:"time"`
}

type ResponeBase

type ResponeBase struct {
	Code int    `json:"code"`
	Msg  string `json:"msg"`
}

type ResponeData

type ResponeData struct {
	ResponeBase
	Data ResponDData `json:"data"`
}

Jump to

Keyboard shortcuts

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