//////////////////////////////////////////////////////////////////////////////// // 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") } }
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) }