Exemplo n.º 1
0
func TestNoneDeleteRoute(t *testing.T) {
	if err := cluster.DeleteRoute(testRoute); err != nil {
		t.Errorf("Failed to DELETE route - %v", err)
		t.FailNow()
	}

	// don't use cluster.GetRoutes()
	routes, err := database.GetRoutes()
	if len(routes) != 0 {
		t.Error("Failed to DELETE route - %v", err)
	}
}
Exemplo n.º 2
0
func deleteRoute(rw http.ResponseWriter, req *http.Request) {
	query := req.URL.Query()
	var route core.Route
	err := parseBody(req, &route)
	if err != nil {
		// check and use query parameters if payload fails
		if len(query) == 0 {
			writeError(rw, req, err, http.StatusBadRequest)
			return
		}
		route = core.Route{SubDomain: query.Get("subdomain"), Domain: query.Get("domain"), Path: query.Get("path")}
	}

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

	writeBody(rw, req, apiMsg{"Success"}, http.StatusOK)
}