github.com/roblesoft/oak@v0.0.0-20230306162712-e6c5c487469e/tree.go (about)

     1  package oak
     2  
     3  type node struct {
     4  	method   string
     5  	path     string
     6  	handler  Handle
     7  	children []*node
     8  }
     9  
    10  func (n *node) getValue() Handle {
    11  	if n != nil {
    12  		return n.handler
    13  	}
    14  	return nil
    15  }
    16  
    17  func (n *node) getNode(path string) *node {
    18  	for n.path != path {
    19  		if len(n.children) == 0 {
    20  			break
    21  		}
    22  		n = n.children[0]
    23  	}
    24  
    25  	if n.path != path {
    26  		return nil
    27  	}
    28  
    29  	return n
    30  }