fix: review API interface.

This commit is contained in:
Daniel Ding
2024-06-15 23:42:31 +08:00
parent 33bf85badd
commit 7c27b06b4e
12 changed files with 118 additions and 37 deletions

View File

@@ -1,11 +1,12 @@
package api
import (
"net/http"
"github.com/gorilla/mux"
"github.com/luscis/openlan/pkg/cache"
"github.com/luscis/openlan/pkg/models"
"github.com/luscis/openlan/pkg/schema"
"net/http"
)
type Route struct {
@@ -38,7 +39,7 @@ func (rt Route) Add(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
id := vars["id"]
worker := GetWorker(id)
worker := Call.GetWorker(id)
if worker == nil {
http.Error(w, "Network not found", http.StatusInternalServerError)
return
@@ -63,7 +64,7 @@ func (rt Route) Del(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
id := vars["id"]
worker := GetWorker(id)
worker := Call.GetWorker(id)
if worker == nil {
http.Error(w, "Network not found", http.StatusInternalServerError)
return
@@ -88,7 +89,7 @@ func (rt Route) Save(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
id := vars["id"]
worker := GetWorker(id)
worker := Call.GetWorker(id)
if worker == nil {
http.Error(w, "Network not found", http.StatusInternalServerError)
return