~andreafeletto/gmnimetr

ccc6c9530b8bc697122e8ac380c9c8ca7eb468e8 — Andrea Feletto 3 months ago 2705777
remove support for loc=<loc> query
1 files changed, 4 insertions(+), 9 deletions(-)

M main.go
M main.go => main.go +4 -9
@@ 92,8 92,7 @@ func renderMissing(loc string) error {
}

// Get the requested location from the `QUERY_STRING` environment variable.
// If the query is of type `loc=<value>` or `<value>` then `value` is returned
// in uppercase.
// If the query is of type `<value>` then `value` is returned in uppercase.
// Otherwise the function returns an error with the appropriate <META> string.
func getLocation() (string, error) {
	query := os.Getenv("QUERY_STRING")


@@ 102,14 101,10 @@ func getLocation() (string, error) {
		return "", errors.New("Wrong query format")
	}

	location := params.Get("loc")
	if location == "" {
		for key := range params {
			location = key
		}
	for key := range params {
		return strings.ToUpper(key), nil
	}

	return strings.ToUpper(location), nil
	return "", nil // unreachable
}

// Fetch data from `url` and unmarshal it into `out`.