Browse Source
			
			
			Add query_string to HTTP replacer and use it for try_files
			
			
				master
			
			
		 
		
			
				
					
						 Matthew Holt
					
					6 years ago
						Matthew Holt
					
					6 years ago
					
				 
				
			 
		 
		
			
				
					
					No known key found for this signature in database
					
						
							GPG Key ID: 2A349DD577D586A5
						
					
				
			
		
		
		
	
		
			
				 2 changed files with 
8 additions and 
2 deletions
			 
			
		 
		
			
				- 
					
					
					 
					modules/caddyhttp/fileserver/caddyfile.go
				
- 
					
					
					 
					modules/caddyhttp/replacer.go
				
				
				
					
						
							
								
									
	
		
		
			
				
					|  | @ -17,9 +17,9 @@ package fileserver | 
			
		
	
		
		
			
				
					|  |  | import ( |  |  | import ( | 
			
		
	
		
		
			
				
					|  |  | 	"encoding/json" |  |  | 	"encoding/json" | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  | 	"github.com/caddyserver/caddy/v2/modules/caddyhttp/rewrite" |  |  |  | 
			
		
	
		
		
			
				
					|  |  | 	"github.com/caddyserver/caddy/v2/caddyconfig/httpcaddyfile" |  |  | 	"github.com/caddyserver/caddy/v2/caddyconfig/httpcaddyfile" | 
			
		
	
		
		
			
				
					|  |  | 	"github.com/caddyserver/caddy/v2/modules/caddyhttp" |  |  | 	"github.com/caddyserver/caddy/v2/modules/caddyhttp" | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 	"github.com/caddyserver/caddy/v2/modules/caddyhttp/rewrite" | 
			
		
	
		
		
			
				
					|  |  | ) |  |  | ) | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  | func init() { |  |  | func init() { | 
			
		
	
	
		
		
			
				
					|  | @ -99,7 +99,7 @@ func parseTryFiles(h httpcaddyfile.Helper) ([]httpcaddyfile.ConfigValue, error) | 
			
		
	
		
		
			
				
					|  |  | 	} |  |  | 	} | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  | 	handler := rewrite.Rewrite{ |  |  | 	handler := rewrite.Rewrite{ | 
			
		
	
		
		
			
				
					
					|  |  | 		URI: "{http.matchers.file.relative}{http.request.uri.query}", |  |  | 		URI: "{http.matchers.file.relative}{http.request.uri.query_string}", | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  | 	} |  |  | 	} | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  | 	matcherSet := map[string]json.RawMessage{ |  |  | 	matcherSet := map[string]json.RawMessage{ | 
			
		
	
	
		
		
			
				
					|  | 
 | 
			
		
	
								
							
						
					 
					
				 
			 
		
			
			
			
			
			
			
				
				
					
						
							
								
									
	
		
		
			
				
					|  | @ -89,6 +89,12 @@ func addHTTPVarsToReplacer(repl caddy.Replacer, req *http.Request, w http.Respon | 
			
		
	
		
		
			
				
					|  |  | 				return dir, true |  |  | 				return dir, true | 
			
		
	
		
		
			
				
					|  |  | 			case "http.request.uri.query": |  |  | 			case "http.request.uri.query": | 
			
		
	
		
		
			
				
					|  |  | 				return req.URL.RawQuery, true |  |  | 				return req.URL.RawQuery, true | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 			case "http.request.uri.query_string": | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 				qs := req.URL.Query().Encode() | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 				if qs != "" { | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 					qs = "?" + qs | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 				} | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 				return qs, true | 
			
		
	
		
		
			
				
					|  |  | 			} |  |  | 			} | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  | 			// hostname labels
 |  |  | 			// hostname labels
 | 
			
		
	
	
		
		
			
				
					|  | 
 |