Examples
This section provides practical examples for common use cases.
Overview
- Basic Usage - Simple GET and POST requests
- HTTP Methods - All HTTP methods (GET, POST, PUT, PATCH, DELETE, HEAD)
- Authentication - Basic auth, Bearer tokens, custom headers
- File Operations - Upload and download files
- Timeout & Retry - Setting timeouts and retrying failed requests
- Proxy - Using HTTP, HTTPS, and SOCKS5 proxies
- Stream - Streaming response data
- Session & Cookies - Session management and cookie handling
- Context Cancellation - Canceling requests with context
- Error Handling - Handling errors and response status codes
Quick Example
go
package main
import (
"fmt"
"github.com/go-zoox/fetch"
)
func main() {
response, err := fetch.Get("https://httpbin.zcorky.com/get")
if err != nil {
panic(err)
}
fmt.Println(response.JSON())
}