From 8f347dd772d7208db8540fceb9160a2f81e3cffa Mon Sep 17 00:00:00 2001 From: TommyDew42 Date: Sun, 19 Jun 2022 21:26:26 +0800 Subject: [PATCH] update documentation for new option enableUnixSocket --- documentation/2-options.md | 22 ++++++++++++++++++++++ documentation/migration-guides/axios.md | 2 +- documentation/migration-guides/request.md | 2 +- documentation/tips.md | 17 +---------------- readme.md | 2 +- 5 files changed, 26 insertions(+), 19 deletions(-) diff --git a/documentation/2-options.md b/documentation/2-options.md index f5e10669a..15b0c539d 100644 --- a/documentation/2-options.md +++ b/documentation/2-options.md @@ -918,6 +918,28 @@ By default, requests will not use [method rewriting](https://datatracker.ietf.or For example, when sending a `POST` request and receiving a `302`, it will resend the body to the new location using the same HTTP method (`POST` in this case). To rewrite the request as `GET`, set this option to `true`. +### `enableUnixSocket` +**Type: `boolean`**\ +**Default: `false`** + +Set to `true` to enable unix socket domain. + +When it is enabled, requests can also be sent via [UNIX Domain Sockets](https://serverfault.com/questions/124517/what-is-the-difference-between-unix-sockets-and-tcp-ip-sockets).\ +Use the following URL scheme: `PROTOCOL://unix:SOCKET:PATH` + +- `PROTOCOL` - `http` or `https` +- `SOCKET` - Absolute path to a unix domain socket, for example: `/var/run/docker.sock` +- `PATH` - Request path, for example: `/v2/keys` + +```js +import got from 'got'; + +await got('http://unix:/var/run/docker.sock:/containers/json'); + +// Or without protocol (HTTP by default) +await got('unix:/var/run/docker.sock:/containers/json'); +``` + ## Methods ### `options.merge(other: Options | OptionsInit)` diff --git a/documentation/migration-guides/axios.md b/documentation/migration-guides/axios.md index f4a457291..54d21d9b4 100644 --- a/documentation/migration-guides/axios.md +++ b/documentation/migration-guides/axios.md @@ -24,7 +24,7 @@ We deeply care about readability, so we renamed these options: - `httpAgent` → [`agent.http`](../2-options.md#agent) - `httpsAgent` → [`agent.https`](../2-options.md#agent) -- `socketPath` → [`url`](../tips.md#unix) +- `socketPath` → [`url`](../2-options.md#enableunixsocket) - `responseEncoding` → [`encoding`](../2-options.md#encoding) - `auth.username` → [`username`](../2-options.md#username) - `auth.password` → [`password`](../2-options.md#password) diff --git a/documentation/migration-guides/request.md b/documentation/migration-guides/request.md index b34329424..2686d8020 100644 --- a/documentation/migration-guides/request.md +++ b/documentation/migration-guides/request.md @@ -46,7 +46,7 @@ These Got options are the same as with Request: - [`localAddress`](../2-options.md#localaddress) - [`headers`](../2-options.md#headers) - [`createConnection`](../2-options.md#createconnection) -- [UNIX sockets](../tips.md#unixsockets): `http://unix:SOCKET:PATH` +- [UNIX sockets](../2-options.md#enableunixsocket): `http://unix:SOCKET:PATH` The `time` option does not exist, assume [it's always true](../6-timeout.md). diff --git a/documentation/tips.md b/documentation/tips.md index 014a28d94..969c251d9 100644 --- a/documentation/tips.md +++ b/documentation/tips.md @@ -89,24 +89,9 @@ for await (const commitData of pagination) { } ``` - ### UNIX Domain Sockets -Requests can also be sent via [UNIX Domain Sockets](https://serverfault.com/questions/124517/what-is-the-difference-between-unix-sockets-and-tcp-ip-sockets).\ -Use the following URL scheme: `PROTOCOL://unix:SOCKET:PATH` - -- `PROTOCOL` - `http` or `https` -- `SOCKET` - Absolute path to a unix domain socket, for example: `/var/run/docker.sock` -- `PATH` - Request path, for example: `/v2/keys` - -```js -import got from 'got'; - -await got('http://unix:/var/run/docker.sock:/containers/json'); - -// Or without protocol (HTTP by default) -await got('unix:/var/run/docker.sock:/containers/json'); -``` +See option [enableUnixSocket](./2-options.md#enableunixsocket) for more. ### Testing diff --git a/readme.md b/readme.md index f06ccf3a5..7f835bc92 100644 --- a/readme.md +++ b/readme.md @@ -202,7 +202,7 @@ For advanced JSON usage, check out the [`parseJson`](documentation/2-options.md# - [x] [RFC compliant caching](documentation/cache.md) - [x] [Proxy support](documentation/tips.md#proxying) -- [x] [Unix Domain Sockets](documentation/tips.md#unix) +- [x] [Unix Domain Sockets](documentation/2-options.md#enableunixsocket) #### Integration