mirror of
				https://github.com/caddyserver/caddy.git
				synced 2025-11-03 19:17:29 -05:00 
			
		
		
		
	httpcaddyfile: Add a couple more placeholder shortcuts (#5015)
This adds:
- `{file.*}` -> `{http.request.uri.path.file.*}`
- `{file_match.*}` -> `{http.matchers.file.*}`
This is a follow-up to #4993 which introduces the new URI file placeholders, and a shortcut for using `file` matcher output.
For example, where the `try_files` directive is a shortcut for this:
```
@try_files file <files...>
rewrite @try_files {http.matchers.file.relative}
```
It could instead be:
```
@try_files file <files...>
rewrite @try_files {file_match.relative}
```
			
			
This commit is contained in:
		
							parent
							
								
									8f6a88e2b0
								
							
						
					
					
						commit
						8cc8f9fddd
					
				@ -95,11 +95,13 @@ func (st ServerType) Setup(inputServerBlocks []caddyfile.ServerBlock,
 | 
			
		||||
		{regexp.MustCompile(`{cookie\.([\w-]*)}`), "{http.request.cookie.$1}"},
 | 
			
		||||
		{regexp.MustCompile(`{labels\.([\w-]*)}`), "{http.request.host.labels.$1}"},
 | 
			
		||||
		{regexp.MustCompile(`{path\.([\w-]*)}`), "{http.request.uri.path.$1}"},
 | 
			
		||||
		{regexp.MustCompile(`{file\.([\w-]*)}`), "{http.request.uri.path.file.$1}"},
 | 
			
		||||
		{regexp.MustCompile(`{query\.([\w-]*)}`), "{http.request.uri.query.$1}"},
 | 
			
		||||
		{regexp.MustCompile(`{re\.([\w-]*)\.([\w-]*)}`), "{http.regexp.$1.$2}"},
 | 
			
		||||
		{regexp.MustCompile(`{vars\.([\w-]*)}`), "{http.vars.$1}"},
 | 
			
		||||
		{regexp.MustCompile(`{rp\.([\w-\.]*)}`), "{http.reverse_proxy.$1}"},
 | 
			
		||||
		{regexp.MustCompile(`{err\.([\w-\.]*)}`), "{http.error.$1}"},
 | 
			
		||||
		{regexp.MustCompile(`{file_match\.([\w-]*)}`), "{http.matchers.file.$1}"},
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for _, sb := range originalServerBlocks {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user