Skip to content

Commit

Permalink
✨ v3 (feature): client refactor (gofiber#1986)
Browse files Browse the repository at this point in the history
* ✨ v3: Move the client module to the client folder and fix the error

* ✨ v3: add xml encoder and decoder

* 🚧 v3: design plugin and hook mechanism, complete simple get request

* 🚧 v3: reset add some field

* 🚧 v3: add doc and fix some error

* 🚧 v3: add header merge

* 🚧 v3: add query param

* 🚧 v3: change to fasthttp's header and args

* ✨ v3: add body and ua setting

* 🚧 v3: add cookie support

* 🚧 v3: add path param support

* ✅ v3: fix error test case

* 🚧 v3: add formdata and file support

* 🚧 v3: referer support

* 🚧 v3: reponse unmarshal

* ✨ v3: finish API design

* 🔥 v3: remove plugin mechanism

* 🚧 v3: add timeout

* 🚧 v3: change path params pattern and add unit test for core

* ✏️ v3: error spell

* ✅ v3: improve test coverage

* ✅ perf: change test func name to fit project format

* 🚧 v3: handle error

* 🚧 v3: add unit test and fix error

* ⚡️ chore: change func to improve performance

* ✅ v3: add some unit test

* ✅ v3: fix error test

* 🐛 fix: add cookie to response

* ✅ v3: add unit test

* ✨ v3: export raw field

* 🐛 fix: fix data race

* 🔒️ chore: change package

* 🐛 fix: data race

* 🐛 fix: test fail

* ✨ feat: move core to req

* 🐛 fix: connection reuse

* 🐛 fix: data race

* 🐛 fix: data race

* 🔀 fix: change to testify

* ✅ fix: fail test in windows

* ✨ feat: response body save to file

* ✨ feat: support tls config

* 🐛 fix: add err check

* 🎨 perf: fix some static check

* ✨ feat: add proxy support

* ✨ feat: add retry feature

* 🐛 fix: static check error

* 🎨 refactor: move som code

* docs: change readme

* ✨ feat: extend axios API

* perf: change field to export field

* ✅ chore: disable startup message

* 🐛 fix: fix test error

* chore: fix error test

* chore: fix test case

* feat: add some test to client

* chore: add test case

* chore: add test case

* ✨ feat: add peek for client

* ✅ chore: add test case

* ⚡️ feat: lazy generate rand string

* 🚧 perf: add config test case

* 🐛 fix: fix merge error

* 🐛 fix utils error

* ✨ add redirection

* 🔥 chore: delete deps

* perf: fix spell error

* 🎨 perf: spell error

* ✨ feat: add logger

* ✨ feat: add cookie jar

* ✨ feat: logger with level

* 🎨 perf: change the field name

* perf: add jar test

* fix proxy test

* improve test coverage

* fix proxy tests

* add cookiejar support from pending fasthttp PR

* fix some lint errors.

* add benchmark for SetValWithStruct

* optimize

* update

* fix proxy middleware

* use panicf instead of errorf and fix panic on default logger

* update

* update

* cleanup comments

* cleanup comments

* fix golang-lint errors

* Update helper_test.go

* add more test cases

* add hostclient pool

* make it more thread safe
-> there is still something which is shared between the requests

* fixed some golangci-lint errors

* fix Test_Request_FormData test

* create new test suite

* just create client for once

* use random port instead of 3000

* remove client pooling and fix test suite

* fix data races on logger tests

* fix proxy tests

* fix global tests

* remove unused code

* fix logger test

* fix proxy tests

* fix linter

* use lock instead of rlock

* fix cookiejar data-race

* fix(client): race conditions

* fix(client): race conditions

* apply some reviews

* change client property name

* apply review

* add parallel benchmark for simple request

* apply review

* apply review

* fix log tests

* fix linter

* fix(client): return error in SetProxyURL instead of panic

---------

Co-authored-by: Muhammed Efe Çetin <efectn@protonmail.com>
Co-authored-by: René Werner <rene.werner@verivox.com>
Co-authored-by: Joey <fenny@gofiber.io>
Co-authored-by: René <rene@gofiber.io>
  • Loading branch information
5 people authored and grivera64 committed Mar 16, 2024
1 parent 47fac3b commit 36180bb
Show file tree
Hide file tree
Showing 21 changed files with 7,885 additions and 2,432 deletions.
1,021 changes: 0 additions & 1,021 deletions client.go

This file was deleted.

35 changes: 35 additions & 0 deletions client/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<h1 align="center">Fiber Client</h1>
<p align="center">Easy-to-use HTTP client based on fasthttp (inspired by <a href="https://github.com/go-resty/resty">resty</a> and <a href="https://github.com/axios/axios">axios</a>)</p>
<p align="center"><a href="#features">Features</a> section describes in detail about Resty capabilities</p>

## Features

> The characteristics have not yet been written.
- GET, POST, PUT, DELETE, HEAD, PATCH, OPTIONS, etc.
- Simple and chainable methods for settings and request
- Request Body can be `string`, `[]byte`, `map`, `slice`
- Auto detects `Content-Type`
- Buffer processing for `files`
- Native `*fasthttp.Request` instance can be accessed during middleware and request execution via `Request.RawRequest`
- Request Body can be read multiple time via `Request.RawRequest.GetBody()`
- Response object gives you more possibility
- Access as `[]byte` by `response.Body()` or access as `string` by `response.String()`
- Automatic marshal and unmarshal for JSON and XML content type
- Default is JSON, if you supply struct/map without header Content-Type
- For auto-unmarshal, refer to -
- Success scenario Request.SetResult() and Response.Result().
- Error scenario Request.SetError() and Response.Error().
- Supports RFC7807 - application/problem+json & application/problem+xml
- Provide an option to override JSON Marshal/Unmarshal and XML Marshal/Unmarshal

## Usage

The following samples will assist you to become as comfortable as possible with `Fiber Client` library.

```go
// Import Fiber Client into your code and refer it as `client`.
import "github.com/gofiber/fiber/client"
```

### Simple GET
Loading

0 comments on commit 36180bb

Please sign in to comment.