Exemplo n.º 1
0
func (r *Router) getKeys(pattern string) []string {
	keys := []string{}

	patternBytes := string551.StringToBytes(pattern)
	coron := false

	keyBytes := []byte{}

	for i := 0; i < len(patternBytes); i++ {
		if patternBytes[i] == 0x3A {
			// 0x3A => ":"
			if !coron {
				keyBytes = []byte{}
				coron = true
			} else {
				keys = append(keys, string551.BytesToString(keyBytes))
				coron = false
			}
		} else {
			if coron {
				keyBytes = append(keyBytes, patternBytes[i])
			}
		}
	}

	return keys
}
Exemplo n.º 2
0
func getBody(resp *http.Response) string {
	b, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return ""
	}

	return string551.BytesToString(b)

}