networkHelper

package
v1.5.54 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2025 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckMixedRouter added in v1.5.6

func CheckMixedRouter(requestRouterFlag string, requestRouterKey int, next http.Handler) http.Handler

CheckMixedRouter 检查混合项目的路由准入

func CheckMixedRouterWithHandler added in v1.5.6

func CheckMixedRouterWithHandler(requestRouterFlag string, handler func(r *http.Request, routerFlag string, routerKeys []int) error, next http.Handler) http.Handler

CheckMixedRouterWithHandler 检查混合项目的路由准入(自定义方法)

func DownloadFile

func DownloadFile(targetURL, localPath string) (fileName, pathString string, err error)

*

  • @func: DownloadFile 下载目标文件到本地
  • @author: Wiidz
  • @date: 2021-6-20

func DownloadFileWithFormat added in v1.5.6

func DownloadFileWithFormat(targetURL, localPath, format string, headers map[string]string) (fileName, tempPath string, header *http.Header, err error)

*

  • @func: DownloadFileWithFormat 下载目标文件到本地,强制命名格式
  • @author: Wiidz
  • @date: 2021-6-20

func GetDomainFromURL added in v1.5.6

func GetDomainFromURL(url string) (domain string)

GetDomainFromURL 从url中提取文件名

func GetFileNameFromURL added in v1.5.6

func GetFileNameFromURL(url string) (wholeName, fileName string, fileType string)

GetFileNameFromURL 从url中提取文件名

func GetJson added in v1.5.6

func GetJson(r *http.Request, target interface{}) error

GetJson 获取body体中的json数据

func GetParsedURL added in v1.5.6

func GetParsedURL(apiURL string, params map[string]interface{}) (string, error)

*

  • @func: GetParsedURL 获取get地址
  • @author: Wiidz
  • @date: 2021-06-20

func GetRequest

func GetRequest(apiURL string, params map[string]interface{}) (map[string]interface{}, *http.Header, error)

*

  • @func: GetRequest 发送get请求
  • @author: Wiidz
  • @date: 2021-06-20

func GetValidatedJson added in v1.5.6

func GetValidatedJson(r *http.Request, target interface{}) error

GetValidatedJson 获取通过validatMng验证过的json数据

func MyRequest added in v1.5.6

func MyRequest(params *networkStruct.MyRequestParams) (resData *networkStruct.MyRequestResp, err error)

MyRequest 自定义请求

func ParamsInvalid added in v1.5.6

func ParamsInvalid(w http.ResponseWriter, err error)

ParamsInvalid json格式返回参数错误

func PostJsonRequest added in v1.5.6

func PostJsonRequest(apiURL string, params map[string]interface{}) ([]byte, error)

*

  • @func: PostRequest 发送post请求
  • @author Wiidz
  • @date 2019-11-16

func PostRequest

func PostRequest(apiURL string, params map[string]interface{}) (map[string]interface{}, *http.Header, error)

*

  • @func: PostRequest 发送post请求
  • @author: Wiidz
  • @date: 2021-6-20

func RequestJson added in v1.5.6

func RequestJson(method networkStruct.Method, targetURL string, params map[string]interface{}, headers map[string]string) (map[string]interface{}, *http.Header, int, error)

func RequestJsonTest added in v1.5.6

func RequestJsonTest(method networkStruct.Method, targetURL string, params map[string]interface{}, headers map[string]string) (map[string]interface{}, *http.Header, int, error)

func RequestJsonWithStruct added in v1.5.6

func RequestJsonWithStruct(
	method networkStruct.Method,
	targetURL string,
	params interface{},
	headers map[string]string,
	iStruct interface{},
	debug bool,
) (interface{}, *http.Header, int, error)

func RequestRaw added in v1.5.6

func RequestRaw(method networkStruct.Method, targetURL string, params map[string]interface{}, headers map[string]string) (string, *http.Header, int, error)

func RequestRawTest added in v1.5.6

func RequestRawTest(method networkStruct.Method, targetURL string, params map[string]interface{}, headers map[string]string) (string, *http.Header, int, error)

func RequestWithStruct added in v1.5.6

func RequestWithStruct(method networkStruct.Method, contentType networkStruct.ContentType, targetURL string, params map[string]interface{}, headers map[string]string, iStruct interface{}) (interface{}, *http.Header, int, error)

func RequestWithStructTest added in v1.5.6

func RequestWithStructTest(method networkStruct.Method, contentType networkStruct.ContentType, targetURL string, params map[string]interface{}, headers map[string]string, iStruct interface{}) (interface{}, *http.Header, int, error)

func ReturnError added in v1.5.6

func ReturnError(w http.ResponseWriter, msg string)

*

  • @func: ReturnResult json格式返回
  • @author Wiidz
  • @date 2019-11-16

func ReturnResult added in v1.5.6

func ReturnResult(w http.ResponseWriter, message string, data interface{}, statusCode int)

func SendRequest added in v1.5.35

func SendRequest(method networkStruct.Method, contentType networkStruct.ContentType, targetURL string, params map[string]interface{}, headers map[string]string) ([]byte, *http.Header, int, error)

func SetRouterFlag added in v1.5.6

func SetRouterFlag(next http.Handler) http.Handler

SetRouterFlag 根据第一个斜线内的自符,记录模块(例如 v1,v2) router_flag 和 router_key 来共同判断路由是否合法

Types

This section is empty.

Jump to

Keyboard shortcuts

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