Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
gqcn committed Nov 24, 2024
1 parent 14a35bf commit 587da3b
Show file tree
Hide file tree
Showing 173 changed files with 228 additions and 228 deletions.
2 changes: 1 addition & 1 deletion docs/release/v2.8 2024-11-18.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ description: '此版本更新包含多个重要改进,包括最低Golang版本
6. `os/gcron`
- 新增`StopGracefully`方法,用于等待当前正在执行的定时任务完成后再停止定时任务:[定时任务-基本使用](../docs/组件列表/系统相关/定时任务-gcron/定时任务-基本使用.md)
7. `os/gfsnotify`
- 改进文件递归监听实现,当监听目录时,如果后续在目录中创建子级目录,或者子级目录的子级目录,以此类推,也将会被递归监听:[文件监控-gfsnotify](../docs/组件列表/系统相关/文件监听-gfsnotify/文件监控-gfsnotify.md)
- 改进文件递归监听实现,当监听目录时,如果后续在目录中创建子级目录,或者子级目录的子级目录,以此类推,也将会被递归监听:[文件监控-gfsnotify](../docs/组件列表/系统相关/文件监控-gfsnotify/文件监控-gfsnotify.md)
8. `test/gtest`
- 改进`AssertIN/AssertNI`断言方法,增加对字符串子串的包含断言支持。
9. `util/gvalid`
Expand Down
8 changes: 4 additions & 4 deletions i18n/en/docusaurus-plugin-content-docs/current.json
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,9 @@
"message": "进程管理-gproc",
"description": "The label for category 进程管理-gproc in sidebar mainSidebar"
},
"sidebar.mainSidebar.category.文件监听-gfsnotify": {
"message": "文件监听-gfsnotify",
"description": "The label for category 文件监听-gfsnotify in sidebar mainSidebar"
"sidebar.mainSidebar.category.文件监控-gfsnotify": {
"message": "文件监控-gfsnotify",
"description": "The label for category 文件监控-gfsnotify in sidebar mainSidebar"
},
"sidebar.mainSidebar.category.文本处理": {
"message": "文本处理",
Expand Down Expand Up @@ -348,7 +348,7 @@
"description": "The label for category 链路跟踪-HTTP示例 in sidebar mainSidebar"
},
"sidebar.mainSidebar.category.链路跟踪-最佳实践": {
"message": "链路跟踪-最佳实践",
"message": "Tracing - Best Practices",
"description": "The label for category 链路跟踪-最佳实践 in sidebar mainSidebar"
},
"sidebar.mainSidebar.category.服务监控告警": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
slug: '/docs/web/http-client-proxy'
title: 'HTTPClient - Proxy Settings'
title: 'HTTPClient - Proxy'
sidebar_position: 7
hide_title: true
keywords: [GoFrame, GoFrame Framework, HTTP Client, Proxy Settings, SetProxy, Proxy Method, HTTP Proxy, SOCKS5 Proxy, Chained Call, HTTP Request]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
---
slug: '/docs/web/http-client-example'
title: 'HTTPClient-Basic Usage'
title: 'HTTPClient - Examples'
sidebar_position: 0
hide_title: true
keywords: [HTTP,GoFrame,GoFrame framework,HTTP client,GET request,POST request,JSON data,DELETE request,ghttp client,network request]
description: "Use the GoFrame framework to send GET, POST, DELETE requests through basic HTTP client operations and process the return values. This article also discusses how to send JSON data with the POST method, use multiple parameters, and map type parameters for requests. Additionally, it provides a brief introduction to *Bytes, *Content, and *Var methods to help developers handle HTTP requests and responses more conveniently."
---

## Basic Usage

The most basic usage of an `HTTP` client is to send requests using several operation methods named after the `HTTP Method`. **It's important to note that the resulting object returned needs to execute `Close` to prevent memory overflow**. Let's look at some simple examples of `HTTP` client requests.

### Sending a `GET` request and printing the return value
## Sending a `GET` request and printing the return value

```go
if r, err := g.Client().Get(ctx, "https://goframe.org"); err != nil {
Expand All @@ -21,7 +19,7 @@ defer r.Close()
fmt.Println(r.ReadAllString())
```

### Sending a `GET` request to download a remote file
## Sending a `GET` request to download a remote file

```go
if r, err := g.Client().Get(ctx, "https://goframe.org/cover.png"); err != nil {
Expand All @@ -33,7 +31,7 @@ gfile.PutBytes("/Users/john/Temp/cover.png", r.ReadAll())

Downloading a file is very simple for small files. It's worth noting that if the remote file is quite large, the server will return data in batches. Thus, the client will need to make multiple `GET` requests, each time requesting the batch file range length through the `Header`. Those interested can research the relevant details.

### Sending a `POST` request and printing the return value
## Sending a `POST` request and printing the return value

```go
if r, err := g.Client().Post(ctx, "http://127.0.0.1:8199/form", "name=john&age=18"); err != nil {
Expand All @@ -45,7 +43,7 @@ fmt.Println(r.ReadAllString())

When passing multiple arguments, users can use the `&` symbol to connect them. Note that parameter values often need to be encoded using `gurl.Encode`.

### Sending a `POST` request with parameters as a `map` type and printing the return value
## Sending a `POST` request with parameters as a `map` type and printing the return value

```go
if r, err := g.Client().Post(
Expand All @@ -64,7 +62,7 @@ fmt.Println(r.ReadAllString())

When passing multiple arguments, users can use the `&` symbol to connect them or directly use `map` (**as previously mentioned, any data type is supported, including `struct`**).

### Sending a `POST` request with parameters as `JSON` data and printing the return value
## Sending a `POST` request with parameters as `JSON` data and printing the return value

```go
if r, err := g.Client().Post(
Expand All @@ -80,7 +78,7 @@ fmt.Println(r.ReadAllString())

As you can see, it's very convenient to send `JSON` data requests via the `ghttp` client, simply by using the `Post` method to submit. When `ContentType` is not explicitly set, the client will automatically recognize the parameter type and set the request's `Content-Type` to `application/json`.

### Sending a `DELETE` request and printing the return value
## Sending a `DELETE` request and printing the return value

```go
if r, err := g.Client().Delete(ctx, "http://user.svc/v1/user/delete/1", "10000"); err != nil {
Expand All @@ -94,7 +92,7 @@ fmt.Println(r.ReadAllString())

Request methods ending with the `Bytes` and `Content` suffix are **shortcut methods** for directly obtaining the return content. These methods will automatically read the content returned by the server **and automatically close the request connection**. The `*Bytes` methods are used to obtain results of type `[]byte`, while the `*Content` methods get results of type `string`. **It's important to note that if the request execution fails, the returned content will be empty.**

### Sending a `GET` request and printing the return value
## Sending a `GET` request and printing the return value

```go
// The returned content is of type []byte
Expand All @@ -106,7 +104,7 @@ content := g.Client().GetBytes(ctx, "https://goframe.org")
content := g.Client().GetContent(ctx, "https://goframe.org")
```

### Sending a `POST` request and printing the return value
## Sending a `POST` request and printing the return value

```go
// The returned content is of type []byte
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
slug: '/docs/web/http-client-faq'
title: 'HTTPClient-FAQ'
title: 'HTTPClient - FAQ'
sidebar_position: 9
hide_title: true
keywords: [HTTPClient,GoFrame,GoFrame Framework,gclient.Client,connection pool,efficient,resource usage,short connection request,form request,ContentType]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
slug: '/docs/web/http-client-middleware'
title: 'HTTPClient-Interceptor/Middleware'
title: 'HTTPClient - Middleware'
sidebar_position: 8
hide_title: true
keywords: [GoFrame, GoFrame Framework, HTTPClient, Interceptor, Middleware, Client Request, Parameter Validation, Signature Generation, API Security, Request Interception]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
slug: '/docs/web/http-client-file-uploading'
title: 'HTTPClient-File Uploading'
title: 'HTTPClient - File Uploading'
sidebar_position: 1
hide_title: true
keywords: [GoFrame,HTTP Client,File Uploading,Server API,Form File,GoFrame Framework,Single File Upload,Multiple File Upload,File Path,Upload Parameters]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
slug: '/docs/web/http-client-metrics'
title: 'HTTPClient-Monitoring Metrics'
title: 'HTTPClient - Metrics'
sidebar_position: 10
hide_title: true
keywords: [HTTP Client, Monitoring Metrics, Performance Optimization, Request Time, GoFrame, Connection Time, Total Requests, Request Size, GoFrame Framework, Response Size]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
slug: '/docs/web/http-client-content-type'
title: 'HTTPClient-Custom ContentType'
title: 'HTTPClient - ContentType'
sidebar_position: 4
hide_title: true
keywords: [GoFrame, GoFrame Framework, HTTPClient, ContentType, Json Request, Xml Request, Custom ContentType, PostContent, url encode, web request]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
slug: '/docs/web/http-client-cookie'
title: 'HTTPClient-Custom Cookie'
title: 'HTTPClient - Cookie'
sidebar_position: 2
hide_title: true
keywords: [HTTPClient, Custom Cookie, GoFrame, GoFrame Framework, SetCookie, SetCookieMap, HTTP Client, ghttp, Cookie, Server]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
slug: '/docs/web/http-client-header'
title: 'HTTPClient-Custom Header'
title: 'HTTPClient - Header'
sidebar_position: 3
hide_title: true
keywords: [HTTPClient, Custom Header, GoFrame, GoFrame Framework, SetHeader, Header Method, Span-Id, Trace-Id, HTTP Request, Client]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
slug: '/docs/web/http-client-transport'
title: 'HTTPClient-Custom Transport'
title: 'HTTPClient - Transport'
sidebar_position: 5
hide_title: true
keywords: [GoFrame, GoFrame framework, HTTPClient, Transport, Unix Socket, Custom Transport, http.Client, gclient.Client, Client Connection Pool, MaxIdleConnsPerHost]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
slug: '/docs/web/http-client-raw-request-response'
title: 'HTTPClient-Request Information Printing'
title: 'HTTPClient - Raw'
sidebar_position: 6
hide_title: true
keywords: [GoFrame, GoFrame Framework, HTTP Client, Request Information Printing, Raw Request, Debugging, Response Information, HTTP Request, Go Language, Web Development]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ It should be noted that `Response` requires a manual call to the `Close` method
1. The `ghttp` client defaults to disabling the `KeepAlive` feature and the verification function for the server's `TLS` certificate. If you need to enable it, you can customize the client's `Transport` attribute.
2. These advanced functions such as **Connection Pool Parameter Setting** and **Connection Proxy Settings** can also be achieved by customizing the client's `Transport` attribute. This data inherits from the standard library's `http.Transport` object.

## Related Documentation
## Documents

import DocCardList from '@theme/DocCardList';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
slug: '/docs/web/session-file'
title: 'Session-File'
title: 'Session - File'
sidebar_position: 0
hide_title: true
keywords: [GoFrame,GoFrame Framework,Session,File Storage,ghttp.Server,StorageFile,gcache,Serialization,Deserialization,Session Management]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
slug: '/docs/web/session-memory'
title: 'Session-Memory'
title: 'Session - Memory'
sidebar_position: 1
hide_title: true
keywords: [GoFrame,Session Storage,Memory Storage,Session Data,StorageMemory,gsession,GoFrame Framework,Session Example,Session Setting,Session Persistence]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
slug: '/docs/web/session-redis-hash-table'
title: 'Session-Redis-HashTable'
title: 'Session - Redis-HashTable'
sidebar_position: 3
hide_title: true
keywords: [GoFrame,GoFrame Framework,RedisHashTableStorage,Session,Redis Storage,Session Management,Go Development,Web Development,Session Expiration,Session Example]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
slug: '/docs/web/session-redis-key-value'
title: 'Session-Redis-KeyValue'
title: 'Session - Redis-KeyValue'
sidebar_position: 2
hide_title: true
keywords: [GoFrame, GoFrame framework, Redis, Session, KeyValue, multi-node deployment, StorageRedis, memory + Redis, JSON serialization, HashTable Storage]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
---
slug: '/docs/web/session-storage'
title: 'Session-Storage API Development'
title: 'Session - Storage Interface'
sidebar_position: 4
hide_title: true
keywords: [GoFrame, GoFrame Framework, gsession, Session-Storage, custom storage, API development, Storage API, TTL, gmap, session management]
description: "Developing Session-Storage APIs using the gsession component in the GoFrame framework. The built-in Storage implementation within the component can meet the needs of most business scenarios. Developers can also customize session storage according to specific cases. The article describes in detail the definition of the Storage API and its invocation timing. To improve session performance, it is recommended to use the gmap container type. This guide will help developers better implement and optimize storage APIs."
keywords: [GoFrame, GoFrame Framework, gsession, Session-Storage, custom storage, interface development, Storage interface, TTL, gmap, session management]
description: "Developing Session-Storage interfaces using the gsession component in the GoFrame framework. The built-in Storage implementation within the component can meet the needs of most business scenarios. Developers can also customize session storage according to specific cases. The article describes in detail the definition of the Storage interface and its invocation timing. To improve session performance, it is recommended to use the gmap container type. This guide will help developers better implement and optimize storage interfaces."
---

In most scenarios, the common `Storage` implementations provided by the built-in `gsession` component are sufficient to meet requirements. If there are special scenarios that require the customization of `Storage`, it is certainly supported, as the functionality of `gsession` is designed with APIs in mind.
In most scenarios, the common `Storage` implementations provided by the built-in `gsession` component are sufficient to meet requirements. If there are special scenarios that require the customization of `Storage`, it is certainly supported, as the functionality of `gsession` is designed with interfaces in mind.

## Storage Definition

[https://github.com/gogf/gf/v2/blob/master/os/gsession/gsession_storage.go](https://github.com/gogf/gf/v2/blob/master/os/gsession/gsession_storage.go)

```go
// Storage is the API definition for session storage.
// Storage is the interface definition for session storage.
type Storage interface {
// New creates a custom session id.
// This function can be used for custom session creation.
Expand Down Expand Up @@ -68,5 +68,5 @@ The timing of each method's invocation is explained in detail within the comment

## Considerations

- In the `Storage` API, not all API methods need to be implemented. Developers only need to implement some APIs according to the specific invocation timing required by their business needs.
- To enhance the execution performance of `Session`, the API uses the `gmap.StrAnyMap` container type. During development, you can refer to this section: [Dictionary Type - gmap](../../组件列表/数据结构/字典类型-gmap/字典类型-gmap.md)
- In the `Storage` interface, not all interface methods need to be implemented. Developers only need to implement some interfaces according to the specific invocation timing required by their business needs.
- To enhance the execution performance of `Session`, the interface uses the `gmap.StrAnyMap` container type. During development, you can refer to this section: [Dictionary Type - gmap](../../组件列表/数据结构/字典类型-gmap/字典类型-gmap.md)
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Taking a common HTTP request as an example, the `Session` object in `ghttp.Reque

When a user's `Session` is no longer needed, for instance, when a user logs out, the session needs to be hard-deleted from storage. This can be done by calling the `RemoveAll` method.

## Related Documentation
## Documents

import DocCardList from '@theme/DocCardList';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
slug: '/docs/web/paging-ajax'
title: 'Pagination Management-Ajax Pagination'
title: 'Pagination - Ajax Paging'
sidebar_position: 2
hide_title: true
keywords: [Ajax Pagination, Pagination Management, Javascript Pagination, GoFrame, GoFrame Framework, Golang, Page Rendering, Front-end Development, Dynamic Pagination, Web Development]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
slug: '/docs/web/paging-template'
title: 'Pagination Management - URL Template'
title: 'Pagination - URL Template'
sidebar_position: 3
hide_title: true
keywords: [GoFrame, GoFrame framework, gpage, pagination management, URL template, custom URL, built-in variables, page rendering, code examples, template replacement]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
slug: '/docs/web/paging-dynamic'
title: 'Paging Management - Dynamic Paging'
title: 'Pagination - Dynamic Paging'
sidebar_position: 0
hide_title: true
keywords: [dynamic paging, GoFrame, paging management, GET parameters, QueryString, paging example, ghttp, gview, GoFrame framework, web application]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
slug: '/docs/web/paging-customization'
title: 'Paging Management-Custom Paging'
title: 'Pagination - Custom Paging'
sidebar_position: 4
hide_title: true
keywords: [Custom Paging, Paging Management, GoFrame, GoFrame Framework, Tag Replacement, Paging Style, Web Development, Regex Matching, Go Language, Framework Usage]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
slug: '/docs/web/paging-static'
title: 'Paging Management - Static Paging'
title: 'Pagination - Static Paging'
sidebar_position: 1
hide_title: true
keywords: [GoFrame, GoFrame Framework, Static Paging, Paging Management, Route Parameters, Fuzzy Matching, Named Matching, Field Matching, Paging Object, Paging Parameters]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
slug: '/docs/web/paging'
title: 'Pagination Management'
title: 'Pagination'
sidebar_position: 10
hide_title: true
keywords: [GoFrame, GoFrame Framework, Pagination Management, gpage Module, Dynamic Pagination, Static Pagination, HTML Pagination, MVC Development, Ajax Pagination, Pagination Style]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: 'Getting Started'
sidebar_position: 0
hide_title: true
keywords: [GoFrame, GoFrame Framework, WebServer, ghttp, Router, Multiple Port Listening, Multi-instance Support, Domain Binding, Routing Features, HTTPS Support]
description: "GoFrame framework provides a powerful WebServer, implemented by the ghttp module, covering features such as routing, session management, and caching. It supports multiple port listening, domain binding, multi-instance operation, offering easy configuration management and server smooth restart capabilities, providing modularity and flexibility support for developers and reliable HTTP and HTTPS services for users."
description: "GoFrame framework provides a powerful WebServer, implemented by the ghttp module, covering features such as routing, session management, and caching. It supports multiple port listening, domain binding, multi-instance operation, offering easy configuration management and server graceful restart capabilities, providing modularity and flexibility support for developers and reliable HTTP and HTTPS services for users."
---
:::tip
`GoFrame` is a modular framework with well-developed infrastructure, where the `WebServer` module is one of the core modules. We choose `Web` service development as the entry point to the framework to make it easier for everyone to learn and understand.
Expand Down Expand Up @@ -206,9 +206,9 @@ This is an example of a mixed routing rule, used to display a specific class, su

The core components of `GoFrame` implement convenient configuration management features, allowing component functionality configuration through configuration file modifications. In most scenarios, we recommend using configuration files to manage component configurations. For `Server` configurations, see the [Service Configuration](服务配置/服务配置.md) chapter.

## Smooth Restart
## Graceful Restart

`Server` has built-in support for smooth restart features. Detailed introduction can be found in the [Smooth Restart Features](高级特性/平滑重启特性.md) chapter.
`Server` has built-in support for graceful restart features. Detailed introduction can be found in the [Graceful Restart Features](高级特性/平滑重启特性.md) chapter.

## HTTPS Support

Expand Down
Loading

0 comments on commit 587da3b

Please sign in to comment.