Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add docs for new client #2991

Merged
merged 15 commits into from
May 13, 2024
22 changes: 10 additions & 12 deletions docs/client/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ description: >-
sidebar_position: 1
---

# Client

The Fiber Client is a powerful HTTP client optimized for high performance and ease of use in server-side applications. Built on top of the robust FastHTTP library, it inherits FastHTTP's high-speed HTTP protocol implementation. The client is designed to make HTTP requests both internally within services or externally to other web services.
efectn marked this conversation as resolved.
Show resolved Hide resolved

## Features
Expand Down Expand Up @@ -690,20 +688,20 @@ Reset clears the Client object
func (c *Client) Reset()
```

# Default Client
## Default Client

Default client is default client object of Gofiber and created using `New()`.
You can configurate it as you wish or replace it with another clients.

## C
### C

C gets default client.

```go title="Signature"
func C()
```

## Replace
### Replace

Replace the defaultClient, the returned function can undo.

Expand All @@ -715,55 +713,55 @@ The default client should not be changed concurrently.
func Replace()
```

## Get
### Get

Get send a get request use defaultClient, a convenient method.
efectn marked this conversation as resolved.
Show resolved Hide resolved

```go title="Signature"
func Get(url string, cfg ...Config) (*Response, error)
```

## Post
### Post

Post send a post request use defaultClient, a convenient method.
efectn marked this conversation as resolved.
Show resolved Hide resolved

```go title="Signature"
func Post(url string, cfg ...Config) (*Response, error)
```

## Head
### Head

Head send a head request use defaultClient, a convenient method.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct the verb form to maintain consistency and grammatical correctness.

- Head send a head request use defaultClient, a convenient method.
+ Head sends a head request using the defaultClient, a convenient method.

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
Head send a head request use defaultClient, a convenient method.
Head sends a head request using the defaultClient, a convenient method.

ReneWerner87 marked this conversation as resolved.
Show resolved Hide resolved

```go title="Signature"
func Head(url string, cfg ...Config) (*Response, error)
```

## Put
### Put

Put send a put request use defaultClient, a convenient method.
ReneWerner87 marked this conversation as resolved.
Show resolved Hide resolved

```go title="Signature"
func Put(url string, cfg ...Config) (*Response, error)
```

## Delete
### Delete

Delete send a delete request use defaultClient, a convenient method.
efectn marked this conversation as resolved.
Show resolved Hide resolved

```go title="Signature"
func Delete(url string, cfg ...Config) (*Response, error)
```

## Options
### Options

Options send a options request use defaultClient, a convenient method.
efectn marked this conversation as resolved.
Show resolved Hide resolved
ReneWerner87 marked this conversation as resolved.
Show resolved Hide resolved

```go title="Signature"
func Options(url string, cfg ...Config) (*Response, error)
```

## Patch
### Patch

Patch send a patch request use defaultClient, a convenient method.
efectn marked this conversation as resolved.
Show resolved Hide resolved

Expand Down
17 changes: 10 additions & 7 deletions docs/client/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
id: examples
title: 🍳 Examples
description: >-
Some useful examples about the client.
Some useful examples about the client.
ReneWerner87 marked this conversation as resolved.
Show resolved Hide resolved
sidebar_position: 5
---

# Basic Auth
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

## Basic Auth

<Tabs>
ReneWerner87 marked this conversation as resolved.
Show resolved Hide resolved
<TabItem value="client" label="Client">
Expand Down Expand Up @@ -68,7 +71,7 @@ func main() {
</TabItem>
</Tabs>

# TLS
## TLS

<Tabs>
<TabItem value="client" label="Client">
Expand Down Expand Up @@ -140,9 +143,9 @@ func main() {
</TabItem>
</Tabs>

# Cookiejar
## Cookiejar

## Request
### Request

```go
func main() {
Expand All @@ -166,7 +169,7 @@ func main() {
<details>
<summary>Click here to see the result</summary>

```
```json
{
"cookies": {
"john": "doe"
Expand All @@ -176,7 +179,7 @@ func main() {
</details>


ReneWerner87 marked this conversation as resolved.
Show resolved Hide resolved
## Response
### Response

```go
func main() {
Expand Down
4 changes: 2 additions & 2 deletions docs/client/hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ With hooks, you can manipulate the client on before request/after response stage

There are 2 kinds of hooks:

# Request Hooks
## Request Hooks

They are called before the HTTP request has been sent. You can use them make changes on Request object.

Expand Down Expand Up @@ -119,7 +119,7 @@ exit status 2
```
</details>

# Response Hooks
## Response Hooks

They are called after the HTTP response has been completed. You can use them to get some information about response and request.

Expand Down
2 changes: 0 additions & 2 deletions docs/client/request.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ description: >-
sidebar_position: 2
---

# Request

The `Request` structure in Gofiber's HTTP client represents an HTTP request. It encapsulates all the necessary information required to send a request to a server. This includes:

- **URL**: The URL to which the request is sent.
Expand Down
2 changes: 0 additions & 2 deletions docs/client/response.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ description: >-
sidebar_position: 3
---

# Response

The `Response` structure in Gofiber's HTTP client represents the server's response to an HTTP request. It contains all the necessary information received from the server. This includes:

- **Status Code**: The HTTP status code returned by the server (e.g., 200 OK, 404 Not Found).
Expand Down