Compare commits
41 Commits
Author | SHA1 | Date |
---|---|---|
dtapps | 930757d4ba | 2 months ago |
dtapps | 4e5e283452 | 2 months ago |
dtapps | b7bd629099 | 3 months ago |
dtapps | 6e875ca329 | 3 months ago |
dtapps | 6e2dd699ff | 3 months ago |
dtapps | b7c59eeabe | 3 months ago |
dtapps | 82bbdc22d3 | 5 months ago |
dtapps | 235c59150f | 6 months ago |
dtapps | 754b5c0b2b | 6 months ago |
dtapps | df7b50a63a | 6 months ago |
dtapps | ad80d76806 | 6 months ago |
dtapps | adb44efa4a | 6 months ago |
dtapps | a37b40e400 | 6 months ago |
dtapps | 295ba66e98 | 6 months ago |
dtapps | 1e0bfa1027 | 6 months ago |
dtapps | 9c3c444997 | 6 months ago |
李光春 | a17d560d7d | 2 years ago |
李光春 | ad0965336d | 2 years ago |
李光春 | 3270d719a4 | 2 years ago |
李光春 | f29f4585db | 2 years ago |
李光春 | 08e4aec244 | 2 years ago |
李光春 | 672f58c1f1 | 2 years ago |
李光春 | c537a026c8 | 2 years ago |
李光春 | a5dec87d88 | 2 years ago |
李光春 | 57494caea7 | 2 years ago |
李光春 | e030ebb553 | 2 years ago |
李光春 | f4f8a0fd31 | 2 years ago |
李光春 | 96d8e4d1fd | 2 years ago |
李光春 | cbf953049e | 2 years ago |
李光春 | f1590dfdcb | 2 years ago |
李光春 | cd4feb9864 | 2 years ago |
李光春 | bf6ddfa970 | 2 years ago |
李光春 | c29fa9c0bb | 2 years ago |
李光春 | d2b64554fc | 2 years ago |
李光春 | c423c38c2e | 2 years ago |
李光春 | 2dc3acfcc2 | 2 years ago |
李光春 | e4ff609f99 | 2 years ago |
李光春 | 83b89ed0c6 | 2 years ago |
李光春 | 4cf6724421 | 2 years ago |
李光春 | 21362ffcb4 | 2 years ago |
李光春 | 1b52cc3467 | 2 years ago |
@ -1,42 +0,0 @@
|
||||
# Use the latest 2.1 version of CircleCI pipeline process engine.
|
||||
# See: https://circleci.com/docs/2.0/configuration-reference
|
||||
version: 2.1
|
||||
|
||||
# Define a job to be invoked later in a workflow.
|
||||
# See: https://circleci.com/docs/2.0/configuration-reference/#jobs
|
||||
jobs:
|
||||
build:
|
||||
working_directory: ~/repo
|
||||
# Specify the execution environment. You can specify an image from Dockerhub or use one of our Convenience Images from CircleCI's Developer Hub.
|
||||
# See: https://circleci.com/docs/2.0/configuration-reference/#docker-machine-macos-windows-executor
|
||||
docker:
|
||||
- image: circleci/golang:1.18
|
||||
# Add steps to the job
|
||||
# See: https://circleci.com/docs/2.0/configuration-reference/#steps
|
||||
steps:
|
||||
- checkout
|
||||
- restore_cache:
|
||||
keys:
|
||||
- go-mod-v4-{{ checksum "go.sum" }}
|
||||
- run:
|
||||
name: Install Dependencies
|
||||
command: go mod download
|
||||
- save_cache:
|
||||
key: go-mod-v4-{{ checksum "go.sum" }}
|
||||
paths:
|
||||
- "/go/pkg/mod"
|
||||
- run:
|
||||
name: Run tests
|
||||
command: |
|
||||
mkdir -p /tmp/test-reports
|
||||
gotestsum --junitfile /tmp/test-reports/unit-tests.xml
|
||||
- store_test_results:
|
||||
path: /tmp/test-reports
|
||||
|
||||
# Invoke jobs via workflows
|
||||
# See: https://circleci.com/docs/2.0/configuration-reference/#workflows
|
||||
workflows:
|
||||
sample: # This is the name of the workflow, feel free to change it to better match your workflow.
|
||||
# Inside the workflow, you define the jobs you want to run.
|
||||
jobs:
|
||||
- build
|
@ -1,38 +0,0 @@
|
||||
name: coverage
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
|
||||
jobs:
|
||||
test:
|
||||
name: Test with Coverage
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.18
|
||||
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
go mod download
|
||||
- name: Run Unit tests
|
||||
run: |
|
||||
go test -race -covermode atomic -coverprofile=covprofile ./...
|
||||
- name: Install goveralls
|
||||
run: go install github.com/mattn/goveralls@latest
|
||||
|
||||
- name: Send coverage
|
||||
env:
|
||||
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: goveralls -coverprofile=covprofile -service=github
|
@ -1,27 +0,0 @@
|
||||
name: Go
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.18
|
||||
|
||||
- name: Test
|
||||
run: go test -v ./...
|
||||
|
||||
- name: Test
|
||||
run: go test ./... -race -coverprofile=coverage.txt -covermode=atomic
|
||||
|
||||
- name: Coverage
|
||||
run: bash <(curl -s https://codecov.io/bash)
|
@ -1,7 +0,0 @@
|
||||
language: go
|
||||
|
||||
go:
|
||||
- master
|
||||
|
||||
script:
|
||||
- go test -v ./...
|
@ -1,25 +1,17 @@
|
||||
<h1>
|
||||
<a href="https://www.dtapp.net/">Golang Request</a>
|
||||
<a href="https://www.dtapp.net/">Golang</a>
|
||||
</h1>
|
||||
|
||||
📦 Golang 请求组件
|
||||
📦 Golang 请求
|
||||
|
||||
[comment]: <> (go)
|
||||
[![godoc](https://pkg.go.dev/badge/go.dtapp.net/gorequest?status.svg)](https://pkg.go.dev/go.dtapp.net/gorequest)
|
||||
[![goproxy.cn](https://goproxy.cn/stats/go.dtapp.net/gorequest/badges/download-count.svg)](https://goproxy.cn/stats/go.dtapp.net/gorequest)
|
||||
[![goreportcard.com](https://goreportcard.com/badge/go.dtapp.net/gorequest)](https://goreportcard.com/report/go.dtapp.net/gorequest)
|
||||
[![deps.dev](https://img.shields.io/badge/deps-go-red.svg)](https://deps.dev/go/go.dtapp.net/gorequest)
|
||||
[![deps.dev](https://img.shields.io/badge/deps-go-red.svg)](https://deps.dev/go/go.dtapp.net%2Fgorequest)
|
||||
|
||||
#### 安装使用
|
||||
#### 安装
|
||||
|
||||
```go
|
||||
go get -v -u go.dtapp.net/gorequest
|
||||
```
|
||||
|
||||
#### 导入
|
||||
|
||||
```go
|
||||
import (
|
||||
"go.dtapp.net/gorequest"
|
||||
)
|
||||
```shell
|
||||
go get -v -u go.dtapp.net/gorequest@v1.0.49
|
||||
```
|
@ -0,0 +1,20 @@
|
||||
package gorequest
|
||||
|
||||
import (
|
||||
"go.dtapp.net/gojson"
|
||||
"go.dtapp.net/gostring"
|
||||
)
|
||||
|
||||
// GetParamsString 获取参数字符串
|
||||
func GetParamsString(src interface{}) string {
|
||||
switch src.(type) {
|
||||
case string:
|
||||
return src.(string)
|
||||
case int, int8, int32, int64:
|
||||
case uint8, uint16, uint32, uint64:
|
||||
case float32, float64:
|
||||
return gostring.ToString(src)
|
||||
}
|
||||
data, _ := gojson.Marshal(src)
|
||||
return string(data)
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package gorequest
|
||||
|
||||
// 定义请求类型
|
||||
var (
|
||||
httpParamsModeJson = "JSON"
|
||||
httpParamsModeXml = "XML"
|
||||
httpParamsModeForm = "FORM"
|
||||
)
|
@ -1,8 +1,44 @@
|
||||
module go.dtapp.net/gorequest
|
||||
|
||||
go 1.18
|
||||
go 1.22
|
||||
|
||||
require (
|
||||
go.dtapp.net/gostring v1.0.3
|
||||
go.dtapp.net/gotime v1.0.2
|
||||
github.com/MercuryEngineering/CookieMonster v0.0.0-20180304172713-1584578b3403
|
||||
go.dtapp.net/gojson v1.0.4
|
||||
go.dtapp.net/gostring v1.0.14
|
||||
go.dtapp.net/gotime v1.0.8
|
||||
go.dtapp.net/gotrace_id v1.0.12
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/basgys/goxml2json v1.1.0 // indirect
|
||||
github.com/bytedance/sonic v1.11.3 // indirect
|
||||
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect
|
||||
github.com/chenzhuoyu/iasm v0.9.1 // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
|
||||
github.com/gin-contrib/sse v0.1.0 // indirect
|
||||
github.com/gin-gonic/gin v1.9.1 // indirect
|
||||
github.com/go-playground/locales v0.14.1 // indirect
|
||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||
github.com/go-playground/validator/v10 v10.19.0 // indirect
|
||||
github.com/goccy/go-json v0.10.2 // indirect
|
||||
github.com/google/go-cmp v0.6.0 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
|
||||
github.com/leodido/go-urn v1.4.0 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.2.0 // indirect
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
||||
github.com/ugorji/go/codec v1.2.12 // indirect
|
||||
go.dtapp.net/gorandom v1.0.3 // indirect
|
||||
golang.org/x/arch v0.7.0 // indirect
|
||||
golang.org/x/crypto v0.22.0 // indirect
|
||||
golang.org/x/net v0.24.0 // indirect
|
||||
golang.org/x/sys v0.19.0 // indirect
|
||||
golang.org/x/text v0.14.0 // indirect
|
||||
google.golang.org/protobuf v1.33.0 // indirect
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
|
@ -1,4 +1,112 @@
|
||||
go.dtapp.net/gostring v1.0.3 h1:KSOq4D77/g5yZN/bqWfZ0kOOaPr/P1240vg03+XdENI=
|
||||
go.dtapp.net/gostring v1.0.3/go.mod h1:+ggrOvgQDQturi1QGsXEpyRN/ZPoRDaqhMujIk5lrgQ=
|
||||
go.dtapp.net/gotime v1.0.2 h1:CFIJHQXC/4t9bsJhk2cLhjHd6rpdPcJXr8BcHKHDuQo=
|
||||
go.dtapp.net/gotime v1.0.2/go.mod h1:Gq7eNLr2iMLP18UNWONRq4V3Uhf/ADp4bIrS+Tc6ktY=
|
||||
github.com/MercuryEngineering/CookieMonster v0.0.0-20180304172713-1584578b3403 h1:EtZwYyLbkEcIt+B//6sujwRCnHuTEK3qiSypAX5aJeM=
|
||||
github.com/MercuryEngineering/CookieMonster v0.0.0-20180304172713-1584578b3403/go.mod h1:mM6WvakkX2m+NgMiPCfFFjwfH4KzENC07zeGEqq9U7s=
|
||||
github.com/basgys/goxml2json v1.1.0 h1:4ln5i4rseYfXNd86lGEB+Vi652IsIXIvggKM/BhUKVw=
|
||||
github.com/basgys/goxml2json v1.1.0/go.mod h1:wH7a5Np/Q4QoECFIU8zTQlZwZkrilY0itPfecMw41Dw=
|
||||
github.com/bitly/go-simplejson v0.5.1 h1:xgwPbetQScXt1gh9BmoJ6j9JMr3TElvuIyjR8pgdoow=
|
||||
github.com/bitly/go-simplejson v0.5.1/go.mod h1:YOPVLzCfwK14b4Sff3oP1AmGhI9T9Vsg84etUnlyp+Q=
|
||||
github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM=
|
||||
github.com/bytedance/sonic v1.10.0-rc/go.mod h1:ElCzW+ufi8qKqNW0FY314xriJhyJhuoJ3gFZdAHF7NM=
|
||||
github.com/bytedance/sonic v1.11.3 h1:jRN+yEjakWh8aK5FzrciUHG8OFXK+4/KrAX/ysEtHAA=
|
||||
github.com/bytedance/sonic v1.11.3/go.mod h1:iZcSUejdk5aukTND/Eu/ivjQuEL0Cu9/rf50Hi0u/g4=
|
||||
github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY=
|
||||
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk=
|
||||
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d h1:77cEq6EriyTZ0g/qfRdp61a3Uu/AWrgIq2s0ClJV1g0=
|
||||
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d/go.mod h1:8EPpVsBuRksnlj1mLy4AWzRNQYxauNi62uWcE3to6eA=
|
||||
github.com/chenzhuoyu/iasm v0.9.0/go.mod h1:Xjy2NpN3h7aUqeqM+woSuuvxmIe6+DDsiNLIrkAmYog=
|
||||
github.com/chenzhuoyu/iasm v0.9.1 h1:tUHQJXo3NhBqw6s33wkGn9SP3bvrWLdlVIJ3hQBL7P0=
|
||||
github.com/chenzhuoyu/iasm v0.9.1/go.mod h1:Xjy2NpN3h7aUqeqM+woSuuvxmIe6+DDsiNLIrkAmYog=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0=
|
||||
github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk=
|
||||
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
|
||||
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
|
||||
github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg=
|
||||
github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU=
|
||||
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
|
||||
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
||||
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
|
||||
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
||||
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
|
||||
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
||||
github.com/go-playground/validator/v10 v10.19.0 h1:ol+5Fu+cSq9JD7SoSqe04GMI92cbn0+wvQ3bZ8b/AU4=
|
||||
github.com/go-playground/validator/v10 v10.19.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM=
|
||||
github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
|
||||
github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
|
||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
||||
github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM=
|
||||
github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
|
||||
github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M=
|
||||
github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
|
||||
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
|
||||
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||
github.com/pelletier/go-toml/v2 v2.2.0 h1:QLgLl2yMN7N+ruc31VynXs1vhMZa7CeHHejIeBAsoHo=
|
||||
github.com/pelletier/go-toml/v2 v2.2.0/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
|
||||
github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE=
|
||||
github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
|
||||
go.dtapp.net/gojson v1.0.4 h1:9en9iyOOLWoEIo2eKhqt3/Djh/3HhwsTpXxgI9efPRo=
|
||||
go.dtapp.net/gojson v1.0.4/go.mod h1:G9CMVzNSRkbNzIic/vJqHCOyKtw6BW2YM8Vyn64zfM0=
|
||||
go.dtapp.net/gorandom v1.0.3 h1:6RNDFMJfLlHFR98c2tbecaMzg4vEIHyEpduMBUdd0jc=
|
||||
go.dtapp.net/gorandom v1.0.3/go.mod h1:Qd6ywCSrk7sCkh9OdR0wygcbQBFt53WDIrx8rqGBvis=
|
||||
go.dtapp.net/gostring v1.0.14 h1:N/2d0F6uUlLB2Co6pEAEyVvhHtoNutG5/J9XLsk6lFs=
|
||||
go.dtapp.net/gostring v1.0.14/go.mod h1:vYgxkyKONIIeUpPkcMCK+1p66AcIe4xeSysSU2R6ysA=
|
||||
go.dtapp.net/gotime v1.0.8 h1:ngKBp7j3Ime1t2jU94gUeshPX1StV5E2x4STlzDMmLU=
|
||||
go.dtapp.net/gotime v1.0.8/go.mod h1:BQT911XSfaJDBYPiEKGFwMjvgnZtx1F3nWu4GTg5ISY=
|
||||
go.dtapp.net/gotrace_id v1.0.12 h1:rUN5RrxGh4rEH87Lfv3Klx+ulZfuv5SYyX7j12Mj8ns=
|
||||
go.dtapp.net/gotrace_id v1.0.12/go.mod h1:brcZxFisvGdeXrHJ9IDJwpDITi4m5Z9sDd9OvGdQHAo=
|
||||
golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
|
||||
golang.org/x/arch v0.7.0 h1:pskyeJh/3AmoQ8CPE95vxHLqp1G1GfGNXTmcl9NEKTc=
|
||||
golang.org/x/arch v0.7.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys=
|
||||
golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30=
|
||||
golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M=
|
||||
golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w=
|
||||
golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8=
|
||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
|
||||
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
|
||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
|
||||
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50=
|
||||
rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=
|
||||
|
@ -0,0 +1,65 @@
|
||||
package gorequest
|
||||
|
||||
// HeaderIsImg 判断是否为图片
|
||||
func (r *Response) HeaderIsImg() bool {
|
||||
if r.ResponseHeader.Get("Content-Type") == "image/jpeg" || r.ResponseHeader.Get("Content-Type") == "image/png" || r.ResponseHeader.Get("Content-Type") == "image/jpg" {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// HeaderIsJpeg 判断是否为jpeg图片
|
||||
func (r *Response) HeaderIsJpeg() bool {
|
||||
if r.ResponseHeader.Get("Content-Type") == "image/jpeg" {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// HeaderIsPng 判断是否为Png图片
|
||||
func (r *Response) HeaderIsPng() bool {
|
||||
if r.ResponseHeader.Get("Content-Type") == "image/png" {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// HeaderIsJpg 判断是否为Jpg图片
|
||||
func (r *Response) HeaderIsJpg() bool {
|
||||
if r.ResponseHeader.Get("Content-Type") == "image/jpg" {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// HeaderJson 判断是否为Json数据
|
||||
func (r *Response) HeaderJson() bool {
|
||||
if r.ResponseHeader.Get("Content-Type") == "application/json" {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// HeaderHtml 判断是否为Html
|
||||
func (r *Response) HeaderHtml() bool {
|
||||
if r.ResponseHeader.Get("Content-Type") == "text/html" || r.ResponseHeader.Get("Content-Type") == "application/xhtml+xml" {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// HeaderTextHtml 判断是否为Html
|
||||
func (r *Response) HeaderTextHtml() bool {
|
||||
if r.ResponseHeader.Get("Content-Type") == "text/html" {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// HeaderXHtml 判断是否为Html
|
||||
func (r *Response) HeaderXHtml() bool {
|
||||
if r.ResponseHeader.Get("Content-Type") == "application/xhtml+xml" {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
package gorequest
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// IsWechatMiniProgramRequest 判断是否是微信小程序
|
||||
func IsWechatMiniProgramRequest(r *http.Request, appid string) error {
|
||||
referer := r.Referer()
|
||||
userAgent := r.UserAgent()
|
||||
if referer == "" {
|
||||
return errors.New("网络请求没有达到要求")
|
||||
}
|
||||
return isWechatMiniProgramRequestReferer(userAgent, referer, appid)
|
||||
}
|
||||
|
||||
// GinIsWechatMiniProgramRequest Gin框架 -> 判断是否是微信小程序
|
||||
// https://gin-gonic.com/zh-cn/docs/
|
||||
//func GinIsWechatMiniProgramRequest(ctx *gin.Context, appid string) error {
|
||||
// referer := ctx.Request.Referer()
|
||||
// userAgent := ctx.Request.UserAgent()
|
||||
// if referer == "" {
|
||||
// return errors.New("网络请求没有达到要求")
|
||||
// }
|
||||
// return isWechatMiniProgramRequestReferer(userAgent, referer, appid)
|
||||
//}
|
||||
|
||||
// IrisIsWechatMiniProgramRequest Iris框架 -> 判断是否是微信小程序
|
||||
// https://www.iris-go.com/docs/
|
||||
//func IrisIsWechatMiniProgramRequest(ctx iris.Context, appid string) error {
|
||||
// referer := ctx.Request().Referer()
|
||||
// userAgent := ctx.Request().UserAgent()
|
||||
// if referer == "" {
|
||||
// return errors.New("网络请求没有达到要求")
|
||||
// }
|
||||
// return isWechatMiniProgramRequestReferer(userAgent, referer, appid)
|
||||
//}
|
||||
|
||||
// EchoIsWechatMiniProgramRequest Echo框架 -> 判断是否是微信小程序
|
||||
// https://echo.labstack.com/docs/
|
||||
//func EchoIsWechatMiniProgramRequest(ctx echo.Context, appid string) error {
|
||||
// referer := ctx.Request().Referer()
|
||||
// userAgent := ctx.Request().UserAgent()
|
||||
// if referer == "" {
|
||||
// return errors.New("网络请求没有达到要求")
|
||||
// }
|
||||
// return isWechatMiniProgramRequestReferer(userAgent, referer, appid)
|
||||
//}
|
@ -0,0 +1,33 @@
|
||||
package gorequest
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// https://developers.weixin.qq.com/miniprogram/dev/framework/ability/network.html#%E4%BD%BF%E7%94%A8%E9%99%90%E5%88%B6
|
||||
func isWechatMiniProgramRequestReferer(userAgent, referer string, appid string) error {
|
||||
// 判断结尾
|
||||
suffix := strings.HasSuffix(referer, "/page-frame.html")
|
||||
if suffix {
|
||||
// 判断开头
|
||||
prefix := strings.HasPrefix(referer, "https://servicewechat.com/")
|
||||
if prefix {
|
||||
// 判断加上appid
|
||||
prefixAppid := strings.HasPrefix(referer, "https://servicewechat.com/"+appid)
|
||||
if prefixAppid {
|
||||
return isWechatMiniProgramRequestUserAgent(userAgent)
|
||||
}
|
||||
return isWechatMiniProgramRequestUserAgent(userAgent)
|
||||
}
|
||||
return errors.New("格式固定不对2")
|
||||
}
|
||||
return errors.New("格式固定不对1")
|
||||
}
|
||||
|
||||
func isWechatMiniProgramRequestUserAgent(userAgent string) error {
|
||||
if strings.Contains(userAgent, "MicroMessenger") {
|
||||
return nil
|
||||
}
|
||||
return errors.New("伪装数据")
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
package gorequest
|
||||
|
||||
import (
|
||||
"log"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestParams(t *testing.T) {
|
||||
params1 := NewParams()
|
||||
params2 := NewParams()
|
||||
params1.Set("a", "1")
|
||||
params2.Set("b", "2")
|
||||
params3 := NewParamsWith(params1, params2)
|
||||
log.Println(params1.DeepCopy())
|
||||
log.Println(params2.DeepCopy())
|
||||
log.Println(params3.DeepCopy())
|
||||
log.Println(params1.DeepCopy())
|
||||
log.Println(params2.DeepCopy())
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
package gorequest
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestUrlParse(t *testing.T) {
|
||||
t.Logf("%+v", UriParse("https://api.dtapp.net/ip?ip=127.0.0.1#history"))
|
||||
t.Logf("%+v", UriParse("https://test:abcd123@golangbyexample.com:8000/tutorials/intro?type=advance&compact=false#history"))
|
||||
t.Logf("%+v", UriFilterExcludeQueryString("/"))
|
||||
t.Logf("%+v", UriFilterExcludeQueryString("/favicon.ico"))
|
||||
t.Logf("%+v", UriFilterExcludeQueryString("/ip"))
|
||||
t.Logf("%+v", UriFilterExcludeQueryString("/ip?ip=127.0.0.1"))
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
package gorequest
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestGetRandomUserAgentSystem(t *testing.T) {
|
||||
t.Log(GetRandomUserAgentSystem())
|
||||
}
|
||||
|
||||
func TestGetRandomUserAgent(t *testing.T) {
|
||||
t.Log(GetRandomUserAgent())
|
||||
}
|
||||
|
||||
func TestDtaUa(t *testing.T) {
|
||||
t.Log(DtaUa())
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
package gorequest
|
||||
|
||||
const Version = "1.0.49"
|
Loading…
Reference in new issue