mirror of
				https://github.com/yggdrasil-network/yggdrasil-go.git
				synced 2025-11-04 03:05:07 +03:00 
			
		
		
		
	Add type core.AddHandlerFunc
This commit is contained in:
		
							parent
							
								
									3613614b41
								
							
						
					
					
						commit
						538ee13669
					
				
					 2 changed files with 6 additions and 4 deletions
				
			
		| 
						 | 
				
			
			@ -38,8 +38,8 @@ type AdminSocketResponse struct {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
type handler struct {
 | 
			
		||||
	args    []string                                   // List of human-readable argument names
 | 
			
		||||
	handler func(json.RawMessage) (interface{}, error) // First is input map, second is output
 | 
			
		||||
	args    []string            // List of human-readable argument names
 | 
			
		||||
	handler core.AddHandlerFunc // First is input map, second is output
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type ListResponse struct {
 | 
			
		||||
| 
						 | 
				
			
			@ -51,7 +51,7 @@ type ListEntry struct {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
// AddHandler is called for each admin function to add the handler and help documentation to the API.
 | 
			
		||||
func (a *AdminSocket) AddHandler(name string, args []string, handlerfunc func(json.RawMessage) (interface{}, error)) error {
 | 
			
		||||
func (a *AdminSocket) AddHandler(name string, args []string, handlerfunc core.AddHandlerFunc) error {
 | 
			
		||||
	if _, ok := a.handlers[strings.ToLower(name)]; ok {
 | 
			
		||||
		return errors.New("handler already exists")
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue