Add request placeholder support for querying request cookies. #1392

Merged
merged 3 commits into from Feb 16, 2017

Projects

None yet

4 participants

@augustoroman
Collaborator
augustoroman commented Feb 1, 2017 edited

This adds the ability to query the request cookies for placeholders
using the syntax "@cookiename".

For example, this would allow rewriting based on a cookie:

  rewrite {
    if {:version} is 'dev'
    to /dev/index.html
  }
@augustoroman augustoroman Add request placeholder support for querying request cookies.
This adds the ability to query the request cookies for placeholders
using the syntax "@cookiename".

For example, this would allow rewriting based on a cookie:
  rewrite {
    if @version is 'dev'
    to /dev/index.html
  }
0d54d1e
@CLAassistant
CLAassistant commented Feb 1, 2017 edited

CLA assistant check
All committers have signed the CLA.

@mholt
Owner
mholt commented Feb 4, 2017

@augustoroman Thanks for the PR! Do you mean this instead?

  rewrite {
    if {@version} is 'dev'
    to /dev/index.html
  }

That's cool. I'm not sure the "@" character is the right one, though, since @ these days feels like a mention. What about ^ or ~?

@augustoroman
Collaborator

@mholt Ooops, yes that's what I meant. I fixed the PR description.

I don't have any strong preference on the particular symbol, I just picked @ since it's round like a cookie. :-)
We could use 🍪 (ref)!

In rough order of preference, I think I like:

{@cookie}
{🍪cookie}
{:cookie}
{~cookie}
{^cookie}
{*cookie}
{©cookie}

Let me know what you preference is and I'll update the PR.

@tobya
Collaborator
tobya commented Feb 4, 2017 edited

Although I like the idea of {🍪cookie} it may be somewhat impractical for the variation in text editors still used today! :)

My vote would be with {:cookie}.

@augustoroman augustoroman Switch cookie special char from @ to :
b9f9fde
@mholt
Owner
mholt commented Feb 4, 2017

The colon looks like chips in a cookie... ha. But... sorry, I'm not sure I like the : because it looks too much like a key-value pair that is missing the key.

I know it's easy to draw correlations to anything else (e.g. "{^name}" looks like a regular expression) but maybe we should reserve the colon for something else if we need to.

I'll think about it? And get back to you. 😄

@augustoroman
Collaborator

Sure, reserving the colon for something like key-value pairs later on is fine, and for some reason I don't like the ^ -- maybe the regular expression similarity is nagging at me. Let's do ~.

@augustoroman augustoroman Switch special char for cookies from : to ~
87dff6a
@mholt
mholt approved these changes Feb 16, 2017 View changes

Yum. 🍪 Thank you for implementing this!

@mholt mholt merged commit dc3efc9 into mholt:master Feb 16, 2017

3 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
licence/cla Contributor License Agreement is signed.
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment