https://github.com/tinh-tinh/fetch
🌐 HTTP client for the Tinh Tinh Framework
https://github.com/tinh-tinh/fetch
framework http-client
Last synced: 2 months ago
JSON representation
🌐 HTTP client for the Tinh Tinh Framework
- Host: GitHub
- URL: https://github.com/tinh-tinh/fetch
- Owner: tinh-tinh
- License: mit
- Created: 2024-09-28T03:30:05.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2025-12-28T09:07:17.000Z (3 months ago)
- Last Synced: 2025-12-30T14:14:04.129Z (3 months ago)
- Topics: framework, http-client
- Language: Go
- Homepage: https://tinh-tinh.github.io/docs/docs/intergrations/fetch
- Size: 44.9 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# HTTP Fetch for Tinh Tinh
## Overview
A flexible, type-safe HTTP client for the Tinh Tinh Framework, inspired by fetch/axios, supporting full-featured requests, easy configuration, and integration with Tinh Tinh modules.
## Install
```bash
go get -u github.com/tinh-tinh/fetch/v2
```
## Features
- Simple and chainable syntax for all HTTP verbs (GET, POST, PUT, PATCH, DELETE, etc.)
- Base URL and per-request configuration
- Automatic JSON encoding/decoding (customizable)
- Query parameter and header support
- Timeout and cancellation (context-based)
- Cookie and credential management
- Response formatting with type inference
- Full integration as a Tinh Tinh module/provider
## Quick Usage
### Create a Fetch Instance
```go
import "github.com/tinh-tinh/fetch/v2"
client := fetch.Create(&fetch.Config{
BaseUrl: "https://jsonplaceholder.typicode.com",
Headers: map[string][]string{
"x-api-key": {"abcd", "efgh"},
},
Timeout: 5 * time.Second,
ResponseType: "json",
})
```
### Make HTTP Requests
```go
// GET with query params
type Query struct {
PostID int `query:"postId"`
}
res := client.Get("comments", &Query{PostID: 1})
// POST with body and query
type Post struct {
UserID int `json:"userId"`
Title string `json:"title"`
Body string `json:"body"`
}
res = client.Post("posts", &Post{UserID: 1, Title: "foo", Body: "bar"}, &Query{PostID: 1})
// PUT, PATCH, DELETE
client.Put("posts/1", &Post{UserID: 1, Title: "updated", Body: "new"}, &Query{PostID: 1})
client.Patch("posts/1", &Post{UserID: 1, Title: "patch", Body: "body"}, &Query{PostID: 1})
client.Delete("posts/1", &Query{PostID: 1})
```
## Contributing
We welcome contributions! Please feel free to submit a Pull Request.
## Support
If you encounter any issues or need help, you can:
- Open an issue in the GitHub repository
- Check our documentation
- Join our community discussions