mirror of
				https://github.com/caddyserver/caddy.git
				synced 2025-10-31 02:27:19 -04:00 
			
		
		
		
	adds unix timestamp placeholder
This commit is contained in:
		
							parent
							
								
									56b3ea876b
								
							
						
					
					
						commit
						f6a96227c4
					
				| @ -287,6 +287,8 @@ func (r *replacer) getSubstitution(key string) string { | |||||||
| 		return now().Format(timeFormat) | 		return now().Format(timeFormat) | ||||||
| 	case "{when_iso}": | 	case "{when_iso}": | ||||||
| 		return now().UTC().Format(timeFormatISOUTC) | 		return now().UTC().Format(timeFormatISOUTC) | ||||||
|  | 	case "{when_unix}": | ||||||
|  | 		return strconv.FormatInt(now().Unix(), 10) | ||||||
| 	case "{file}": | 	case "{file}": | ||||||
| 		_, file := path.Split(r.request.URL.Path) | 		_, file := path.Split(r.request.URL.Path) | ||||||
| 		return file | 		return file | ||||||
|  | |||||||
| @ -75,6 +75,7 @@ func TestReplace(t *testing.T) { | |||||||
| 		{"The response status is {status}.", "The response status is 200."}, | 		{"The response status is {status}.", "The response status is 200."}, | ||||||
| 		{"{when}", "02/Jan/2006:15:04:05 +0000"}, | 		{"{when}", "02/Jan/2006:15:04:05 +0000"}, | ||||||
| 		{"{when_iso}", "2006-01-02T15:04:12Z"}, | 		{"{when_iso}", "2006-01-02T15:04:12Z"}, | ||||||
|  | 		{"{when_unix}", "1136214252"}, | ||||||
| 		{"The Custom header is {>Custom}.", "The Custom header is foobarbaz."}, | 		{"The Custom header is {>Custom}.", "The Custom header is foobarbaz."}, | ||||||
| 		{"The CustomAdd header is {>CustomAdd}.", "The CustomAdd header is caddy."}, | 		{"The CustomAdd header is {>CustomAdd}.", "The CustomAdd header is caddy."}, | ||||||
| 		{"The request is {request}.", "The request is POST /?foo=bar HTTP/1.1\\r\\nHost: localhost\\r\\n" + | 		{"The request is {request}.", "The request is POST /?foo=bar HTTP/1.1\\r\\nHost: localhost\\r\\n" + | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user