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

Redirect when_unix greater_than/less_than #2594

Closed
SteffenDE opened this issue May 3, 2019 · 3 comments
Closed

Redirect when_unix greater_than/less_than #2594

SteffenDE opened this issue May 3, 2019 · 3 comments
Labels
feature ⚙️ New feature or request
Milestone

Comments

@SteffenDE
Copy link

1. What would you like to have changed?

Allow redirecting based on datetime placeholders like {when_unix}. The http.rewrite conditions currently do not allow something like greater_than or less_than for comparing integers.

2. Why is this feature a useful, necessary, and/or important addition to this project?

It would be very useful to allow specifying a date after which a redirect should occur, e.g. after a deprecation deadline.

3. What alternatives are there, or what are you doing in the meantime to work around the lack of this feature?

Manually editing the Caddyfile after the deadline to redirect users to the new address.

@SteffenDE SteffenDE added the feature ⚙️ New feature or request label May 3, 2019
@mholt mholt added this to the 2.0 milestone Jul 18, 2019
@mholt
Copy link
Member

mholt commented Jul 18, 2019

This is really easy to add to Caddy 2. Interested in contributing it?

@mholt
Copy link
Member

mholt commented May 21, 2020

Pending on google/cel-go#357

@mholt mholt closed this as completed in 0cbf467 May 22, 2020
@mholt
Copy link
Member

mholt commented May 22, 2020

@SteffenDE Here's how to do it with the expression matcher (in v2.1)

@then expression `{time.now} > timestamp(1590106550)`

(The backticks aren't necessary in this case, but I like to enclose the expression in a single token for readability.)

You can also pass an RFC3339-formatted string into CEL's timestamp() function to make it a timestamp.

@mholt mholt modified the milestones: 2.x, 2.1 May 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature ⚙️ New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants