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

caddyhttp: Add map handler #3199

Merged
merged 9 commits into from
Jun 26, 2020
Merged

caddyhttp: Add map handler #3199

merged 9 commits into from
Jun 26, 2020

Conversation

sarge
Copy link
Collaborator

@sarge sarge commented Mar 27, 2020

Simple map implementation. #2824

Open to suggestions around hybrid implementations or other data types.

Maps are resolved during request pipeline at the point in the pipeline, I did consider deferring evaluation to the point of substitution.

[edit]
A recurring idea I have for this feature is to make it more caddy-like, somehow taking the idea of matchers. It does make it more verbose specifying a matcher for each case.

map [dest_var] {
   [matcher] [value]
   ...
}

map $is_an_image {
   path /img/* true
   path /images/* true
   path_regexp *.[jpg|bmp] true
   default false
}

@mholt
Copy link
Member

mholt commented Mar 27, 2020

Thanks Sarge! Excited to take a look at this more. However, the major features tree for 2.0 is closed now so the earliest we'd see a module like this is in 2.1.

@mholt mholt added the under review 🧐 Review is pending before merging label Mar 27, 2020
@mholt mholt added this to the 2.1 milestone Mar 27, 2020
@francislavoie francislavoie changed the title Add map caddyhttp: Add map handler Apr 19, 2020
@francislavoie francislavoie linked an issue Apr 19, 2020 that may be closed by this pull request
@francislavoie
Copy link
Member

francislavoie commented May 14, 2020

@sarge think you could rebase? 🙂

@mholt
Copy link
Member

mholt commented May 14, 2020

FYI, I am still thinking about this one.

Copy link
Member

@mholt mholt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this @sarge -- I'm still trying to design final upgrades for v2.1 but I think there's a place for a map directive (and handler) like this. These comments are my first pass, there will likely be more.

modules/caddyhttp/map/map.go Outdated Show resolved Hide resolved
modules/caddyhttp/map/map.go Outdated Show resolved Hide resolved
modules/caddyhttp/map/map.go Outdated Show resolved Hide resolved
modules/caddyhttp/map/caddyfile.go Outdated Show resolved Hide resolved
modules/caddyhttp/map/map.go Outdated Show resolved Hide resolved
modules/caddyhttp/map/map.go Outdated Show resolved Hide resolved
modules/caddyhttp/map/caddyfile.go Outdated Show resolved Hide resolved
replacer.go Outdated Show resolved Hide resolved
replacer.go Outdated Show resolved Hide resolved
@mholt mholt modified the milestones: 2.1, 2.2 Jun 8, 2020
@sarge
Copy link
Collaborator Author

sarge commented Jun 15, 2020

@mholt I think I have addressed the first round of feedback. Thanks for that.

Copy link
Member

@mholt mholt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the revisions! We're getting there :)

modules/caddyhttp/map/map.go Outdated Show resolved Hide resolved
modules/caddyhttp/map/map.go Outdated Show resolved Hide resolved
replacer.go Outdated Show resolved Hide resolved
modules/caddyhttp/map/caddyfile.go Outdated Show resolved Hide resolved
caddyconfig/httpcaddyfile/directives.go Outdated Show resolved Hide resolved
@mholt
Copy link
Member

mholt commented Jun 26, 2020

Let's give this a spin in the 2.2 dev tree, then. Thanks for working on this, @sarge!

@mholt mholt removed the under review 🧐 Review is pending before merging label Jun 26, 2020
@mholt mholt merged commit 6004d3f into caddyserver:master Jun 26, 2020
@francislavoie francislavoie modified the milestones: v2.2.0, v2.1.1 Jul 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

A equivalent for nginx map module
3 participants