mirror of
https://github.com/luscis/openlan.git
synced 2025-10-16 14:00:42 +08:00
fea: support add findhop.
This commit is contained in:
@@ -26,7 +26,7 @@ func (rt Route) List(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
worker := Call.GetWorker(id)
|
||||
if worker == nil {
|
||||
http.Error(w, "Network not found", http.StatusInternalServerError)
|
||||
http.Error(w, "Network not found", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -42,18 +42,18 @@ func (rt Route) Add(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
worker := Call.GetWorker(id)
|
||||
if worker == nil {
|
||||
http.Error(w, "Network not found", http.StatusInternalServerError)
|
||||
http.Error(w, "Network not found", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
pr := &schema.PrefixRoute{}
|
||||
if err := GetData(r, pr); err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
if err := worker.AddRoute(pr, rt.Switcher); err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -66,18 +66,18 @@ func (rt Route) Del(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
worker := Call.GetWorker(id)
|
||||
if worker == nil {
|
||||
http.Error(w, "Network not found", http.StatusInternalServerError)
|
||||
http.Error(w, "Network not found", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
pr := &schema.PrefixRoute{}
|
||||
if err := GetData(r, pr); err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
if err := worker.DelRoute(pr, rt.Switcher); err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ func (rt Route) Save(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
worker := Call.GetWorker(id)
|
||||
if worker == nil {
|
||||
http.Error(w, "Network not found", http.StatusInternalServerError)
|
||||
http.Error(w, "Network not found", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user