https://github.com/wmentor/ua
http user agent
https://github.com/wmentor/ua
golang golang-library http http-client https library user-agent
Last synced: 3 months ago
JSON representation
http user agent
- Host: GitHub
- URL: https://github.com/wmentor/ua
- Owner: wmentor
- License: mit
- Created: 2020-06-16T19:20:56.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-01-02T12:37:22.000Z (about 2 years ago)
- Last Synced: 2025-01-14T06:54:11.618Z (12 months ago)
- Topics: golang, golang-library, http, http-client, https, library, user-agent
- Language: Go
- Size: 4.88 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Simple http client
# Summary
* Use tiny Go
* Require Go version >= 1.20
* Minimum external dependencies
* Simple in usage
# Install
```
go get github.com/wmentor/ua
```
# Usage
```go
package main
import (
"fmt"
"strings"
"time"
"github.com/wmentor/ua"
)
func main() {
agent := ua.New()
agent.Timeout = time.Second * 5
agent.UserAgent = "Mozilla"
agent.Decode = true // deconde to utf-8
headers := map[string]string{"X-Request-Id": "12313"}
data := strings.NewReader("content body")
resp, err := agent.Request( "POST", "https://someurl.ru", headers, data)
if err != nil || resp == nil {
panic("request failed")
}
if resp.StatusCode != 200 {
panic("invalid status code")
}
fmt.Println(string(resp.Content))
}
```