You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/utilities.md
+59-3Lines changed: 59 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -590,7 +590,7 @@ The `lapis.http` module will attempt to select an HTTP client that works in the
590
590
current server/environment. All of these modules should implement LuaSocket's
591
591
`request` function interface. See: <https://lunarmodules.github.io/luasocket/http.html#request>
592
592
593
-
* When using Nginx: `lapis.nginx.http`
593
+
* When using Nginx: `lapis.nginx.http` (automatically uses `lapis.nginx.resty_http` in timer phases)
594
594
* When using Cqueues/lua-http: `http.compat.socket`
595
595
* Default: LuaSocket's `socket.http` (Note: `luasec` is required to perform HTTPS requests)
596
596
@@ -747,8 +747,11 @@ parameters of LuaSocket's request function.
747
747
The `/proxy` location described above must exist in the same server block that
748
748
is handling the original request for this function to work.
749
749
750
-
> If you are looking for a more flexible HTTP client that is specific to Nginx,
751
-
> look at <https://github.com/ledgetech/lua-resty-http>
750
+
> Lapis also provides `lapis.nginx.resty_http`, an HTTP client built on
751
+
> [lua-resty-http](https://github.com/ledgetech/lua-resty-http). It is
752
+
> automatically used in timer phases (where `location.capture` doesn't work),
753
+
> but can also be used directly. See [Using
754
+
> lua-resty-http](#using-lua-resty-http) below for more details.
752
755
753
756
**Parameters:**
754
757
@@ -773,6 +776,59 @@ Every successful HTTP request increments the following performance metrics in th
773
776
-`http_count`: This metric counts the total number of HTTP requests.
774
777
-`http_time`: This metric measures the total time taken for HTTP requests. It is calculated as the difference between the current time and the start time of the request.
775
778
779
+
### Using lua-resty-http
780
+
781
+
Lapis provides an HTTP client built on
782
+
[lua-resty-http](https://github.com/ledgetech/lua-resty-http) in the
783
+
`lapis.nginx.resty_http` module. It implements the same LuaSocket `http.request`
784
+
interface as the other Lapis HTTP clients.
785
+
786
+
This client is automatically used when making HTTP requests from timer phase
787
+
contexts (`ngx.timer.*` callbacks), since nginx's `location.capture` doesn't
788
+
work in those phases. You can also require and use it directly:
0 commit comments