// FindMethod conforms to the same API as initialRoot, but we'll always return (nil, err)
970603
func (r *errRoot) FindMethod(rootName string, version int, methodName string) (rpcreflect.MethodCaller, error) {
	return nil, r.err
}
313120
func (mm *methodManager) AddMethod(
	name string, obj interface{}, alias string, option ...Options) {
	if obj == nil {
		panic("obj can't be nil")
	}
	f := reflect.ValueOf(obj).MethodByName(name)
	if alias != "" {
		name = alias
	}
	if f.CanInterface() {
		mm.AddFunction(name, f, option...)
	}
}
788883
func GetMethodSpec(client, method string) (spec *MethodSpec) {

	// Default spec for all clients and methods
	//
	//   - Never panic
	//   - Never return redisError
	//   - Never return nil/zerovalue for any non-error result

	defspec := &MethodSpec{
		NoPanics:         true,
		NoRedisErr:       true,
		NoNilResultValue: true,
		NoNilFuture:      true,
	}

	// Allow client specific mods to the default spec, as required.
	//
	switch client {
	case "Client":
		spec = syncClientMethodSpec(defspec, method)
	case "AsyncClient":
		spec = asyncClientMethodSpec(defspec, method)
	case "PubSubClient":
		spec = pubsubClientMethodSpec(defspec, method)
	}

	return
}
1235314
func (r *Router) checkMethod(node *Trie, method string) http.Handler {
	for _, h := range node.Handler {
		if h.Method == "ALL" {
			return h.Handler
		}
		if h.Method == method {
			return h.Handler
		}
	}
	if r.NotAllowedHandler != nil {
		return r.NotAllowedHandler
	}
	return r.MethodNotAllowed()
}
869624
func parseMethodName(methodName string) (service, method string, _ error) {
	if !strings.HasPrefix(methodName, "/") {
		return "", "", errors.New("invalid method name: should start with /")
	}
	methodName = methodName[1:]

	pos := strings.LastIndex(methodName, "/")
	if pos < 0 {
		return "", "", errors.New("invalid method name: suffix /method is missing")
	}
	return methodName[:pos], methodName[pos+1:], nil
}
1206813
func (r *Router) Find(method, path string) (handlers []Handler, params map[string]string) {
	pvalues := make([]string, r.maxParams)
	handlers, pnames := r.find(method, path, pvalues)
	params = make(map[string]string, len(pnames))
	for i, n := range pnames {
		params[n] = pvalues[i]
	}
	return handlers, params
}
576320
func BuildMatchesMethod(mo []string, fx RHandler) RHandler {
	return func(w http.ResponseWriter, r *http.Request, c Collector) {
		MatchesMethod(mo, w, r, c, fx)
	}
}
14526
func (r *router) MethodsFor(path string) []string {
	methods := []string{}
	for _, route := range r.getRoutes() {
		matches := route.regex.FindStringSubmatch(path)
		if len(matches) > 0 && matches[0] == path && !hasMethod(methods, route.method) {
			methods = append(methods, route.method)
		}
	}
	return methods
}
254460
func (f *Request) Method(method string) *Request {
	f.method = method
	return f
}
361979
func (a *Wrapper) RouteMethods() {
	if _, valid := a.Controller.(Initer); !valid {
		a.Server.Core.Logger().Infof("%T is no method Init(*Context),skip.", a.Controller)
		return
	}
	t := reflect.TypeOf(a.Controller)
	e := t.Elem()
	ctlPath := e.PkgPath() + ".(*" + e.Name() + ")."
	//github.com/webx-top/{Project}/app/{App}/controller.(*Index).
	ctl := strings.ToLower(e.Name())

	for i := t.NumMethod() - 1; i >= 0; i-- {
		m := t.Method(i)
		name := m.Name
		fn := name
		h := func(u *Url) func(ctx echo.Context) error {
			return func(ctx echo.Context) error {
				c := X(ctx)
				if !u.ValidExt(c.Format) {
					return c.HTML(404, `The contents can not be displayed in this format: `+c.Format)
				}
				v := reflect.New(e)
				ac := v.Interface()
				if err := c.Init(a.App, ac, e.Name(), name); err != nil {
					return err
				}
				if err := ac.(Initer).Init(c); err != nil {
					return err
				}
				if a.HasBefore {
					if err := ac.(Before).Before(); err != nil {
						return err
					}
					if c.Exit {
						return nil
					}
				}
				format := strings.ToUpper(c.Format)
				m := v.MethodByName(fn + `_` + c.Method() + format)
				if !m.IsValid() {
					m = v.MethodByName(fn + `_` + c.Method())
					if !m.IsValid() {
						m = v.MethodByName(fn + `_` + format)
						if !m.IsValid() {
							m = v.MethodByName(fn)
						}
					}
				}
				if r, err := a.SafelyCall(m, []reflect.Value{}); err != nil {
					return err
				} else if len(r) > 0 {
					if err, ok := r[0].Interface().(error); ok && err != nil {
						return c.DisplayError(err.Error())
					}
				}
				if a.HasAfter {
					if c.Exit {
						return nil
					}
					return ac.(After).After()
				}
				return nil
			}
		}
		if strings.HasSuffix(name, `_ANY`) {
			name = strings.TrimSuffix(name, `_ANY`)
			path := "/" + ctl + "/" + strings.ToLower(name)
			u := a.App.Server.URL.SetByKey(path, ctlPath+name+"-fm")
			handler := echo.HandlerFunc(h(u))
			a.Webx.Any(path, handler)
			for strings.HasSuffix(path, `/index`) {
				path = strings.TrimSuffix(path, `/index`)
				a.Webx.Any(path+`/`, handler)
			}
			continue
		}
		matches := methodSuffixRegex.FindAllString(name, 1)
		if len(matches) < 1 {
			continue
		}
		methods := strings.Split(strings.TrimPrefix(matches[0], `_`), `_`)
		name = strings.TrimSuffix(name, matches[0])
		path := "/" + ctl + "/" + strings.ToLower(name)
		u := a.App.Server.URL.SetByKey(path, ctlPath+name+"-fm")
		handler := echo.HandlerFunc(h(u))
		a.Webx.Match(methods, path, handler)
		for strings.HasSuffix(path, `/index`) {
			path = strings.TrimSuffix(path, `/index`)
			a.Webx.Match(methods, path+`/`, handler)
		}
	}
}
682047
func WithMethod(method string) PrepareDecorator {
	return func(p Preparer) Preparer {
		return PreparerFunc(func(r *http.Request) (*http.Request, error) {
			r.Method = method
			return p.Prepare(r)
		})
	}
}
647081
func initAuthMethod() {
	var signers []ssh.Signer

	// If there's a running SSH Agent, try to use its Private keys.
	sock, err := net.Dial("unix", os.Getenv("SSH_AUTH_SOCK"))
	if err == nil {
		agent := agent.NewClient(sock)
		signers, _ = agent.Signers()
	}

	// Try to read user's SSH private keys form the standard paths.
	files, _ := filepath.Glob(os.Getenv("HOME") + "/.ssh/id_*")
	for _, file := range files {
		if strings.HasSuffix(file, ".pub") {
			continue // Skip public keys.
		}
		data, err := ioutil.ReadFile(file)
		if err != nil {
			continue
		}
		signer, err := ssh.ParsePrivateKey(data)
		if err != nil {
			continue
		}
		signers = append(signers, signer)

	}
	authMethod = ssh.PublicKeys(signers...)
}
377531
func (self *Request) SetMethod(method string) *Request {
	self.Method = strings.ToUpper(method)
	return self
}
1231544
func MatchMethod(req *http.Request, ereq *Request) (bool, error) {
	return ereq.Method == "" || req.Method == ereq.Method, nil
}
470340
func (self *DefaultRequest) GetMethod() string {
	self.once.Do(self.prepare)
	return self.Method
}
523369
func FindMethodForService(s *pb.ServiceDescriptorProto, name string) int {
	for i, x := range s.GetMethod() {
		if x.GetName() == name {
			return i
		}
	}
	return -1
}
1248049
func (tc *TeleportClient) authMethods() []ssh.AuthMethod {
	m := append([]ssh.AuthMethod(nil), tc.Config.AuthMethods...)
	if tc.LocalAgent() != nil {
		m = append(m, tc.LocalAgent().AuthMethods()...)
	}
	return m
}