mirror of
				https://github.com/traefik/traefik.git
				synced 2025-10-31 16:31:16 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			27 lines
		
	
	
		
			534 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			27 lines
		
	
	
		
			534 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| package udp
 | |
| 
 | |
| import (
 | |
| 	"github.com/traefik/traefik/v3/pkg/safe"
 | |
| )
 | |
| 
 | |
| // HandlerSwitcher is a switcher implementation of the Handler interface.
 | |
| type HandlerSwitcher struct {
 | |
| 	handler safe.Safe
 | |
| }
 | |
| 
 | |
| // ServeUDP implements the Handler interface.
 | |
| func (s *HandlerSwitcher) ServeUDP(conn *Conn) {
 | |
| 	handler := s.handler.Get()
 | |
| 	h, ok := handler.(Handler)
 | |
| 	if ok {
 | |
| 		h.ServeUDP(conn)
 | |
| 	} else {
 | |
| 		conn.Close()
 | |
| 	}
 | |
| }
 | |
| 
 | |
| // Switch replaces s handler with the given handler.
 | |
| func (s *HandlerSwitcher) Switch(handler Handler) {
 | |
| 	s.handler.Set(handler)
 | |
| }
 |