master
李光春 2 years ago
parent 4cf6724421
commit 83b89ed0c6

@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2018 茂名聚合科技有限公司 Copyright (c) 2018 李光春
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

@ -2,24 +2,26 @@
<a href="https://www.dtapp.net/">Golang Request</a> <a href="https://www.dtapp.net/">Golang Request</a>
</h1> </h1>
📦 Golang 请求组件 📦 Golang 请求
[comment]: <> (go) [comment]: <> (go)
[![godoc](https://pkg.go.dev/badge/go.dtapp.net/gorequest?status.svg)](https://pkg.go.dev/go.dtapp.net/gorequest) [![godoc](https://pkg.go.dev/badge/github.com/dtapps/gorequest?status.svg)](https://pkg.go.dev/github.com/dtapps/gorequest)
[![goproxy.cn](https://goproxy.cn/stats/go.dtapp.net/gorequest/badges/download-count.svg)](https://goproxy.cn/stats/go.dtapp.net/gorequest) [![goproxy.cn](https://goproxy.cn/stats/github.com/dtapps/gorequest/badges/download-count.svg)](https://goproxy.cn/stats/github.com/dtapps/gorequest)
[![goreportcard.com](https://goreportcard.com/badge/go.dtapp.net/gorequest)](https://goreportcard.com/report/go.dtapp.net/gorequest) [![goreportcard.com](https://goreportcard.com/badge/github.com/dtapps/gorequest)](https://goreportcard.com/report/github.com/dtapps/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/github.com%2Fdtapps%2Fgorequest)
#### 安装使用 #### 安装
```go ```go
go get -v -u go.dtapp.net/gorequest go get -v -u github.com/dtapps/gorequest
``` ```
#### 导入 #### 使用
```go ```go
import ( package main
"go.dtapp.net/gorequest"
) func main() {
}
``` ```

@ -0,0 +1,12 @@
package gorequest
const (
userAgentFormat = "%s/GO/%s"
)
// 定义请求类型
var (
httpParamsModeJson = "JSON"
httpParamsModeXml = "XML"
httpParamsModeForm = "FORM"
)

@ -1,8 +1,7 @@
module go.dtapp.net/gorequest module github.com/dtapps/gorequest
go 1.18 go 1.18
require ( require go.dtapp.net/gostring v1.0.3
go.dtapp.net/gostring v1.0.3
go.dtapp.net/gotime v1.0.2 require github.com/dtapps/gotime v1.0.3
)

@ -1,4 +1,4 @@
github.com/dtapps/gotime v1.0.3 h1:yzknDbqEOqntn3fbE2T9HRY5d03B81iIUkYKESuE8TY=
github.com/dtapps/gotime v1.0.3/go.mod h1:lbp8pG/8aV3O+t7IuAjasL2WLBsZqLZG6Uw6KqSnox8=
go.dtapp.net/gostring v1.0.3 h1:KSOq4D77/g5yZN/bqWfZ0kOOaPr/P1240vg03+XdENI= 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/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=

@ -6,7 +6,7 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"go.dtapp.net/gotime" "github.com/dtapps/gotime"
"io" "io"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
@ -16,8 +16,6 @@ import (
"time" "time"
) )
var userAgentFormat = "DtApp-Request/%s (%s) GO/%s"
// Response 返回内容 // Response 返回内容
type Response struct { type Response struct {
RequestUri string //【请求】链接 RequestUri string //【请求】链接
@ -47,13 +45,6 @@ type App struct {
p12Cert *tls.Certificate // p12证书内容 p12Cert *tls.Certificate // p12证书内容
} }
// 定义
var (
httpParamsModeJson = "JSON"
httpParamsModeXml = "XML"
httpParamsModeForm = "FORM"
)
// NewHttp 实例化 // NewHttp 实例化
func NewHttp() *App { func NewHttp() *App {
return &App{ return &App{
@ -199,7 +190,7 @@ func request(app *App) (httpResponse Response, err error) {
} }
} }
httpResponse.RequestHeader.Set("Sdk-User-Agent", fmt.Sprintf(userAgentFormat, Version, runtime.GOOS, runtime.Version())) httpResponse.RequestHeader.Set("Sdk-User-Agent", fmt.Sprintf(userAgentFormat, runtime.GOOS, runtime.Version()))
switch app.httpContentType { switch app.httpContentType {
case httpParamsModeJson: case httpParamsModeJson:
httpResponse.RequestHeader.Set("Content-Type", "application/json") httpResponse.RequestHeader.Set("Content-Type", "application/json")

@ -1,3 +1,3 @@
package gorequest package gorequest
const Version = "1.0.20" const Version = "1.0.21"

Loading…
Cancel
Save