time condition
OpenResty Edge provides two types of time conditions.
- Absolute time: used to represent the time range
- Relative time: used to represent periods
Within the time interval, Not Within the time interval
- Variable: time
- Operator: within the time interval, not within the time interval
- Value: start time and end time
Example:
Add 2 Page Rules:
- If within the time range, output “Within”
- If not within, output “Not Within”
Example result:
$ curl http://test.com/ -v
* Trying 10.0.0.200:80...
* Connected to test.com (10.0.0.200) port 80 (#0)
> GET / HTTP/1.1
> Host: test.com
> User-Agent: curl/7.79.1
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Date: Wed, 12 Oct 2022 07:38:31 GMT
< Content-Type: text/plain
< Transfer-Encoding: chunked
< Connection: keep-alive
< Server: openresty+
< Req-ID: 00000080000447e7a7b80006
<
* Connection #0 to host test.com left intact
Within
Within the time period, Not within the time period
- Variable: time
- Operator: within the time period, not within the time period
- Value: week, start time of each day, end time of each day. For example, Monday and Tuesday from 8:00 to 10:00.
Example:
Add 2 Page rules:
- If within the time period, output “Within”
- If not within the time period, output “Not Within”
Example result:
$ curl http://test.com/ -v
* Trying 10.0.0.200:80...
* Connected to test.com (10.0.0.200) port 80 (#0)
> GET / HTTP/1.1
> Host: test.com
> User-Agent: curl/7.79.1
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Date: Wed, 12 Oct 2022 07:45:32 GMT
< Content-Type: text/plain
< Transfer-Encoding: chunked
< Connection: keep-alive
< Server: openresty+
< Req-ID: 00000080000447e7b4e00007
<
* Connection #0 to host test.com left intact
Not Within