Esempio n. 1
0
////////////////////////////////////////////////////////////////////////////////
// ROUTES
////////////////////////////////////////////////////////////////////////////////
func TestNoneSetRoute(t *testing.T) {
	if err := cluster.SetRoute(testRoute); err != nil {
		t.Errorf("Failed to SET route - %v", err)
		t.FailNow()
	}

	routes, err := database.GetRoutes()
	if err != nil {
		t.Error(err)
	}

	if len(routes) != 1 || routes[0].Domain != testRoute.Domain {
		t.Errorf("Read route differs from written route")
	}
}
Esempio n. 2
0
func postRoute(rw http.ResponseWriter, req *http.Request) {
	var route core.Route
	err := parseBody(req, &route)
	if err != nil {
		writeError(rw, req, err, http.StatusBadRequest)
		return
	}

	// save to cluster
	err = cluster.SetRoute(route)
	if err != nil {
		writeError(rw, req, err, http.StatusInternalServerError)
		return
	}

	writeBody(rw, req, route, http.StatusOK)
}