mirror of
				https://github.com/AlexxIT/go2rtc.git
				synced 2025-10-31 11:46:26 +08:00 
			
		
		
		
	Rewrite get handlers code
This commit is contained in:
		| @@ -17,17 +17,20 @@ func HandleFunc(scheme string, handler Handler) { | |||||||
| 	handlers[scheme] = handler | 	handlers[scheme] = handler | ||||||
| } | } | ||||||
|  |  | ||||||
| func HasProducer(url string) bool { | func getHandler(url string) Handler { | ||||||
| 	i := strings.IndexByte(url, ':') | 	i := strings.IndexByte(url, ':') | ||||||
| 	if i <= 0 { // TODO: i < 4 ? | 	if i <= 0 { // TODO: i < 4 ? | ||||||
| 		return false | 		return nil | ||||||
| 	} | 	} | ||||||
| 	return handlers[url[:i]] != nil | 	return handlers[url[:i]] | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func HasProducer(url string) bool { | ||||||
|  | 	return getHandler(url) != nil | ||||||
| } | } | ||||||
|  |  | ||||||
| func GetProducer(url string) (streamer.Producer, error) { | func GetProducer(url string) (streamer.Producer, error) { | ||||||
| 	i := strings.IndexByte(url, ':') | 	handler := getHandler(url) | ||||||
| 	handler := handlers[url[:i]] |  | ||||||
| 	if handler == nil { | 	if handler == nil { | ||||||
| 		return nil, fmt.Errorf("unsupported scheme: %s", url) | 		return nil, fmt.Errorf("unsupported scheme: %s", url) | ||||||
| 	} | 	} | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Alexey Khit
					Alexey Khit