golanggohlsrtmpwebrtcmedia-serverobs-studiortcprtmp-proxyrtmp-serverrtprtsprtsp-proxyrtsp-relayrtsp-serversrtstreamingwebrtc-proxy
		
		
		
		
			You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							63 lines
						
					
					
						
							1.0 KiB
						
					
					
				
			
		
		
	
	
							63 lines
						
					
					
						
							1.0 KiB
						
					
					
				package conf | 
						|
 | 
						|
import ( | 
						|
	"encoding/json" | 
						|
	"fmt" | 
						|
) | 
						|
 | 
						|
// AuthMethod is an authentication method. | 
						|
type AuthMethod int | 
						|
 | 
						|
// authentication methods. | 
						|
const ( | 
						|
	AuthMethodInternal AuthMethod = iota | 
						|
	AuthMethodHTTP | 
						|
	AuthMethodJWT | 
						|
) | 
						|
 | 
						|
// MarshalJSON implements json.Marshaler. | 
						|
func (d AuthMethod) MarshalJSON() ([]byte, error) { | 
						|
	var out string | 
						|
 | 
						|
	switch d { | 
						|
	case AuthMethodInternal: | 
						|
		out = "internal" | 
						|
 | 
						|
	case AuthMethodHTTP: | 
						|
		out = "http" | 
						|
 | 
						|
	default: | 
						|
		out = "jwt" | 
						|
	} | 
						|
 | 
						|
	return json.Marshal(out) | 
						|
} | 
						|
 | 
						|
// UnmarshalJSON implements json.Unmarshaler. | 
						|
func (d *AuthMethod) UnmarshalJSON(b []byte) error { | 
						|
	var in string | 
						|
	if err := json.Unmarshal(b, &in); err != nil { | 
						|
		return err | 
						|
	} | 
						|
 | 
						|
	switch in { | 
						|
	case "internal": | 
						|
		*d = AuthMethodInternal | 
						|
 | 
						|
	case "http": | 
						|
		*d = AuthMethodHTTP | 
						|
 | 
						|
	case "jwt": | 
						|
		*d = AuthMethodJWT | 
						|
 | 
						|
	default: | 
						|
		return fmt.Errorf("invalid authMethod: '%s'", in) | 
						|
	} | 
						|
 | 
						|
	return nil | 
						|
} | 
						|
 | 
						|
// UnmarshalEnv implements env.Unmarshaler. | 
						|
func (d *AuthMethod) UnmarshalEnv(_ string, v string) error { | 
						|
	return d.UnmarshalJSON([]byte(`"` + v + `"`)) | 
						|
}
 | 
						|
 |