Exemplo n.º 1
0
// BuildParams builds params for SignParams.
func BuildParams(params map[string]string) url.Values {
	var sortedKeys []string

	for k := range params {
		sortedKeys = append(sortedKeys, k)
	}

	natsort.Sort(sortedKeys)

	values := url.Values{}
	for _, k := range sortedKeys {
		v := params[k]
		if v != "" {
			values.Add(k, v)
		}
	}

	return values
}
Exemplo n.º 2
0
func (s *Server) handleAPIGroups(c *gin.Context) {
	gs := set.New(set.ThreadSafe)

	// Get unique sets of groups names
	hosts, _ := s.poller.GetHosts()
	for _, h := range hosts {
		for _, g := range h.Groups {
			gs.Add(g)
		}

		for _, s := range h.Services {
			for _, g := range s.Groups {
				gs.Add(g)
			}
		}
	}

	result := set.StringSlice(gs)
	natsort.Sort(result)

	c.Header("Cache-Control", "private, max-age=0")
	c.JSON(http.StatusOK, result)
}