Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/opus-domini/fast-shot
Hit your API targets with rapid-fire precision using Go's fastest and simple HTTP Client.
https://github.com/opus-domini/fast-shot
go golang golang-library http-client rest
Last synced: about 1 month ago
JSON representation
Hit your API targets with rapid-fire precision using Go's fastest and simple HTTP Client.
- Host: GitHub
- URL: https://github.com/opus-domini/fast-shot
- Owner: opus-domini
- License: mit
- Created: 2023-09-16T05:29:29.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-03-10T20:23:54.000Z (3 months ago)
- Last Synced: 2024-03-10T21:29:30.496Z (3 months ago)
- Topics: go, golang, golang-library, http-client, rest
- Language: Go
- Homepage:
- Size: 1.11 MB
- Stars: 28
- Watchers: 2
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Lists
- awesome-go - fast-shot - Hit your API targets with rapid-fire precision using Go's fastest and simple HTTP Client. (Networking / HTTP Clients)
- awesome-stars-eryajf - opus-domini/fast-shot - Hit your API targets with rapid-fire precision using Go's fastest and simple HTTP Client. (Go)
- awesome-go-cn - fast-shot - fire precision using Go's fastest and simple HTTP Client. [![近一周有更新][G]](https://github.com/opus-domini/fast-shot) [![godoc][D]](https://godoc.org/github.com/opus-domini/fast-shot) (网络 / HTTP客户端)
- awesome-go-stars - fast-shot - Hit your API targets with rapid-fire precision using Go's fastest and simple HTTP Client. (Networking / HTTP Clients)
- awesome-go-cn - fast-shot - fire precision using Go's fastest and simple HTTP Client. [![godoc][D]](https://godoc.org/github.com/opus-domini/fast-shot) (网络 / HTTP客户端)
- awesome-go - fast-shot - Hit your API targets with rapid-fire precision using Go's fastest and simple HTTP Client. (Networking / HTTP Clients)
- awesome-go-with-stars - fast-shot - Hit your API targets with rapid-fire precision using Go's fastest and simple HTTP Client. (Networking / HTTP Clients)
- awesome-ccamel - opus-domini/fast-shot - Hit your API targets with rapid-fire precision using Go's fastest and simple HTTP Client. (Go)
- awesome-go - fast-shot - Hit your API targets with rapid-fire precision using Go's fastest and simple HTTP Client. (Networking / HTTP Clients)
- awesome-go - fast-shot - Hit your API targets with rapid-fire precision using Go's fastest and simple HTTP Client. (Networking / HTTP Clients)
README
Fast Shot is a robust, feature-rich, and highly configurable HTTP client for Go. Crafted with modern Go practices in mind, it offers a fluent, chainable API that allows for clean, idiomatic code.
## Why Fast Shot?
* **Fluent & Chainable API**: Write expressive, readable, and flexible HTTP client code.
* **Ease of Use**: Reduce boilerplate, making HTTP requests as straightforward as possible.
* **Rich Features**: From headers to query parameters and JSON support, Fast Shot covers your needs.## Features 🌟
* Fluent API for HTTP requests
* Extensible authentication
* Customizable HTTP headers
* Query parameter manipulation
* JSON request and response support
* Built-in error handling
* Well-tested## Installation 🔧
To install Fast Shot, run the following command:
```bash
go get github.com/opus-domini/fast-shot
```## Quick Start 🚀
Here's how you can make a simple POST using Fast Shot:
```go
package mainimport (
"fmt"
fastshot "github.com/opus-domini/fast-shot"
"github.com/opus-domini/fast-shot/constant/mime"
)func main() {
client := fastshot.NewClient("https://api.example.com").
Auth().BearerToken("your_token_here").
Build()payload := map[string]interface{}{
"key1": "value1",
"key2": "value2",
}response, err := client.POST("/endpoint").
Header().AddAccept(mime.JSON).
Body().AsJSON(payload).
Send()
// Process response...
}
```## Advanced Usage 🛠️
### Fluent API
Easily chain multiple settings in a single line:
```go
client := fastshot.NewClient("https://api.example.com").
Auth().BearerToken("your-bearer-token").
Header().Add("My-Header", "My-Value").
Config().SetTimeout(time.Second * 30).
Build()
```
### Retry MechanismHandle transient failures, enhancing the reliability of your HTTP requests:
```go
client.POST("/resource").
Retry().Set(2, time.Second * 2).
Send()
```### Out-of-the-Box Support for Client Load Balancing
Effortlessly manage multiple endpoints:
```go
client := fastshot.NewClientLoadBalancer([]string{
"https://api1.example.com",
"https://api2.example.com",
"https://api3.example.com",
}).
Config().SetTimeout(time.Second * 10).
Build()
```This feature allows you to distribute network traffic across several servers, enhancing the performance and reliability of your applications.
### Authentication
Fast Shot supports various types of authentication:
```go
// Bearer Token
builder.Auth().BearerToken("your-bearer-token")// Basic Authentication
builder.Auth().BasicAuth("username", "password")// Custom Authentication
builder.Auth().Set("custom-authentication-header")
```### Custom Headers and Cookies
Add your own headers and cookies effortlessly:
```go
// Add Custom Header
builder.Header().
Add("header", "value")// Add Multiple Custom Headers
builder.Header().
AddAll(map[string]string{
"key1": "value1",
"key2": "value2",
"key3": "value3",
})// Add Custom Cookie
builder.Cookie().
Add(&http.Cookie{Name: "session_id", Value: "id"})
```### Advanced Configurations
Control every aspect of the HTTP client:
```go
// Set Timeout
builder.Config().
SetTimeout(time.Second * 30)// Set Follow Redirect
builder.Config().
SetFollowRedirects(false)// Set Custom Transport
builder.Config().
SetCustomTransport(myCustomTransport)// Set Proxy
builder.Config().
SetProxy("http://my-proxy-server:port")
````## Contributing 🤝
Your contributions are always welcome! Feel free to create pull requests, submit issues, or contribute in any other way.