github.com/simpleiot/simpleiot@v0.18.3/api/shiftpath.go (about)

     1  package api
     2  
     3  import (
     4  	"path"
     5  	"strings"
     6  )
     7  
     8  // ShiftPath is used to extract on segement of URL for processing
     9  func ShiftPath(p string) (head, tail string) {
    10  	p = path.Clean("/" + p)
    11  	i := strings.Index(p[1:], "/") + 1
    12  	if i <= 0 {
    13  		return p[1:], "/"
    14  	}
    15  	return p[1:i], p[i:]
    16  }