mirror of
				https://github.com/caddyserver/caddy.git
				synced 2025-10-31 02:27:19 -04:00 
			
		
		
		
	
		
			
				
	
	
		
			30 lines
		
	
	
		
			689 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			30 lines
		
	
	
		
			689 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| package httpserver
 | |
| 
 | |
| import (
 | |
| 	"net/http"
 | |
| 	"strings"
 | |
| )
 | |
| 
 | |
| // Path represents a URI path.
 | |
| type Path string
 | |
| 
 | |
| // Matches checks to see if other matches p.
 | |
| //
 | |
| // Path matching will probably not always be a direct
 | |
| // comparison; this method assures that paths can be
 | |
| // easily and consistently matched.
 | |
| func (p Path) Matches(other string) bool {
 | |
| 	if CaseSensitivePath {
 | |
| 		return strings.HasPrefix(string(p), other)
 | |
| 	}
 | |
| 	return strings.HasPrefix(strings.ToLower(string(p)), strings.ToLower(other))
 | |
| }
 | |
| 
 | |
| // PathMatcher is a Path RequestMatcher.
 | |
| type PathMatcher string
 | |
| 
 | |
| // Match satisfies RequestMatcher.
 | |
| func (p PathMatcher) Match(r *http.Request) bool {
 | |
| 	return Path(r.URL.Path).Matches(string(p))
 | |
| }
 |