Example #1
0
// OrderParams gets the parameters ordered by key, then by values as a URL string.
func OrderParams(values url.Values) string {

	// get the keys
	var keys []string
	for k, _ := range values {
		keys = append(keys, k)
	}

	// sort the keys
	sort.Strings(keys)

	// ordered items
	var ordered []string

	// sort the values
	for _, key := range keys {
		sort.Strings(values[key])
		for _, val := range values[key] {
			ordered = append(ordered, stewstrings.MergeStrings(key, "=", val))
		}
	}

	joined := stewstrings.JoinStrings("&", ordered...)
	return joined

}
Example #2
0
// String gets a nicely formatted string of the trace data.
func (t *Tracer) String() string {

	if t == nil {
		return ""
	}

	t.Process()

	return strings.MergeStrings("\n", strings.JoinStrings("\n", t.StringData()...))
}
Example #3
0
// ResourcePath gets the path for this Resource.
func (r *TestResource) ResourcePath() string {

	// break the path apart
	pathSegments := strings.Split(r.Path, common.PathSeparator)

	// do we have an ID in the data?
	if id, hasID := r.Data[common.DataFieldID]; hasID {
		// do we have an ID in the path?
		if len(pathSegments)%2 == 0 {
			// update the ID
			pathSegments[len(pathSegments)-1] = id.(string)
		} else {
			// add the ID
			pathSegments = append(pathSegments, id.(string))
		}
	}

	return stewstrings.JoinStrings(common.PathSeparator, pathSegments...)
}
Example #4
0
// Path generates a path from the given arguments.
//
// For example:
//
//     Path("people", person.ID(), "books", book.ID())
func Path(items ...string) string {
	return strings.Trim(stewstrings.JoinStrings(common.PathSeparator, items...), common.PathSeparator)
}