spaceapid/util/util.go

21 lines
491 B
Go
Raw Normal View History

package util
import (
"fmt"
"strings"
)
// GetSensorURLPath generates the URL path for the given sensor details.
// location and name may be optional depending on sensorType, see the schema definition for details.
// The path is always all-lowercase.
func GetSensorURLPath(sensorType, location, name string) string {
path := fmt.Sprintf("/sensors/%s", sensorType)
if location != "" {
path += "/" + location
}
if name != "" {
path += "/" + name
}
return strings.ToLower(path)
}