mirror of
				https://github.com/caddyserver/caddy.git
				synced 2025-11-03 19:17:29 -05:00 
			
		
		
		
	* Create request_id directive #1590 * Address Comments * Fix TestListenerAddrEqual * requestid: Add some tests * Address Comments by tobya * Address Comments
		
			
				
	
	
		
			28 lines
		
	
	
		
			478 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			28 lines
		
	
	
		
			478 B
		
	
	
	
		
			Go
		
	
	
	
	
	
package requestid
 | 
						|
 | 
						|
import (
 | 
						|
	"github.com/mholt/caddy"
 | 
						|
	"github.com/mholt/caddy/caddyhttp/httpserver"
 | 
						|
)
 | 
						|
 | 
						|
func init() {
 | 
						|
	caddy.RegisterPlugin("requestid", caddy.Plugin{
 | 
						|
		ServerType: "http",
 | 
						|
		Action:     setup,
 | 
						|
	})
 | 
						|
}
 | 
						|
 | 
						|
func setup(c *caddy.Controller) error {
 | 
						|
	for c.Next() {
 | 
						|
		if c.NextArg() {
 | 
						|
			return c.ArgErr() //no arg expected.
 | 
						|
		}
 | 
						|
	}
 | 
						|
 | 
						|
	httpserver.GetConfig(c).AddMiddleware(func(next httpserver.Handler) httpserver.Handler {
 | 
						|
		return Handler{Next: next}
 | 
						|
	})
 | 
						|
 | 
						|
	return nil
 | 
						|
}
 |