Example #1
0
func (s *fakeGalebServer) createPool(w http.ResponseWriter, r *http.Request) {
	var pool galebClient.Pool
	pool.Status = "OK"
	json.NewDecoder(r.Body).Decode(&pool)
	poolsWithName := s.findItemByName("pool", pool.Name)
	if len(poolsWithName) > 0 {
		w.WriteHeader(http.StatusConflict)
		return
	}
	s.idCounter++
	pool.ID = s.idCounter
	pool.Links.Self.Href = fmt.Sprintf("http://%s%s/%d", r.Host, r.URL.String(), pool.ID)
	s.pools[strconv.Itoa(pool.ID)] = &pool
	w.Header().Set("Location", pool.Links.Self.Href)
	w.WriteHeader(http.StatusCreated)
}