func()

in internal/registry/registry.go [81:101]


func (r *Registry) register(function *RegisteredFunction, options ...Option) error {
	for _, o := range options {
		o(function)
	}
	if function.Name == "" && function.Path == "" {
		return fmt.Errorf("either the function path or the function name should be specified")
	}
	if function.Name == "" {
		// The function is not registered declaratively.
		r.functionsWithoutNames = append(r.functionsWithoutNames, function)
		return nil
	}
	if _, ok := r.functions[function.Name]; ok {
		return fmt.Errorf("function name already registered: %q", function.Name)
	}
	if function.Path == "" {
		function.Path = "/" + function.Name
	}
	r.functions[function.Name] = function
	return nil
}