X-Git-Url: https://gerrit.fd.io/r/gitweb?p=govpp.git;a=blobdiff_plain;f=binapi%2Fvpe%2Fvpe_http.ba.go;fp=binapi%2Fvpe%2Fvpe_http.ba.go;h=cf663800eadf68ccb07f3c06c538697e791f8b3b;hp=8998c9e5e2aeed586c9c47655c8bbd166501390e;hb=4102c72bce694babd94a481b1201d33895a6f9c5;hpb=a4112fac7b86fe09650d2bb57969fe46404edd7d diff --git a/binapi/vpe/vpe_http.ba.go b/binapi/vpe/vpe_http.ba.go index 8998c9e..cf66380 100644 --- a/binapi/vpe/vpe_http.ba.go +++ b/binapi/vpe/vpe_http.ba.go @@ -4,215 +4,11 @@ package vpe import ( "encoding/json" - "io/ioutil" "net/http" ) func HTTPHandler(rpc RPCService) http.Handler { mux := http.NewServeMux() - mux.HandleFunc("/add_node_next", func(w http.ResponseWriter, req *http.Request) { - var request = new(AddNodeNext) - b, err := ioutil.ReadAll(req.Body) - if err != nil { - http.Error(w, "read body failed", http.StatusBadRequest) - return - } - if err := json.Unmarshal(b, request); err != nil { - http.Error(w, "unmarshal data failed", http.StatusBadRequest) - return - } - reply, err := rpc.AddNodeNext(req.Context(), request) - if err != nil { - http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError) - return - } - rep, err := json.MarshalIndent(reply, "", " ") - if err != nil { - http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError) - return - } - w.Write(rep) - }) - mux.HandleFunc("/cli", func(w http.ResponseWriter, req *http.Request) { - var request = new(Cli) - b, err := ioutil.ReadAll(req.Body) - if err != nil { - http.Error(w, "read body failed", http.StatusBadRequest) - return - } - if err := json.Unmarshal(b, request); err != nil { - http.Error(w, "unmarshal data failed", http.StatusBadRequest) - return - } - reply, err := rpc.Cli(req.Context(), request) - if err != nil { - http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError) - return - } - rep, err := json.MarshalIndent(reply, "", " ") - if err != nil { - http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError) - return - } - w.Write(rep) - }) - mux.HandleFunc("/cli_inband", func(w http.ResponseWriter, req *http.Request) { - var request = new(CliInband) - b, err := ioutil.ReadAll(req.Body) - if err != nil { - http.Error(w, "read body failed", http.StatusBadRequest) - return - } - if err := json.Unmarshal(b, request); err != nil { - http.Error(w, "unmarshal data failed", http.StatusBadRequest) - return - } - reply, err := rpc.CliInband(req.Context(), request) - if err != nil { - http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError) - return - } - rep, err := json.MarshalIndent(reply, "", " ") - if err != nil { - http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError) - return - } - w.Write(rep) - }) - mux.HandleFunc("/control_ping", func(w http.ResponseWriter, req *http.Request) { - var request = new(ControlPing) - reply, err := rpc.ControlPing(req.Context(), request) - if err != nil { - http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError) - return - } - rep, err := json.MarshalIndent(reply, "", " ") - if err != nil { - http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError) - return - } - w.Write(rep) - }) - mux.HandleFunc("/get_f64_endian_value", func(w http.ResponseWriter, req *http.Request) { - var request = new(GetF64EndianValue) - b, err := ioutil.ReadAll(req.Body) - if err != nil { - http.Error(w, "read body failed", http.StatusBadRequest) - return - } - if err := json.Unmarshal(b, request); err != nil { - http.Error(w, "unmarshal data failed", http.StatusBadRequest) - return - } - reply, err := rpc.GetF64EndianValue(req.Context(), request) - if err != nil { - http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError) - return - } - rep, err := json.MarshalIndent(reply, "", " ") - if err != nil { - http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError) - return - } - w.Write(rep) - }) - mux.HandleFunc("/get_f64_increment_by_one", func(w http.ResponseWriter, req *http.Request) { - var request = new(GetF64IncrementByOne) - b, err := ioutil.ReadAll(req.Body) - if err != nil { - http.Error(w, "read body failed", http.StatusBadRequest) - return - } - if err := json.Unmarshal(b, request); err != nil { - http.Error(w, "unmarshal data failed", http.StatusBadRequest) - return - } - reply, err := rpc.GetF64IncrementByOne(req.Context(), request) - if err != nil { - http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError) - return - } - rep, err := json.MarshalIndent(reply, "", " ") - if err != nil { - http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError) - return - } - w.Write(rep) - }) - mux.HandleFunc("/get_next_index", func(w http.ResponseWriter, req *http.Request) { - var request = new(GetNextIndex) - b, err := ioutil.ReadAll(req.Body) - if err != nil { - http.Error(w, "read body failed", http.StatusBadRequest) - return - } - if err := json.Unmarshal(b, request); err != nil { - http.Error(w, "unmarshal data failed", http.StatusBadRequest) - return - } - reply, err := rpc.GetNextIndex(req.Context(), request) - if err != nil { - http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError) - return - } - rep, err := json.MarshalIndent(reply, "", " ") - if err != nil { - http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError) - return - } - w.Write(rep) - }) - mux.HandleFunc("/get_node_graph", func(w http.ResponseWriter, req *http.Request) { - var request = new(GetNodeGraph) - reply, err := rpc.GetNodeGraph(req.Context(), request) - if err != nil { - http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError) - return - } - rep, err := json.MarshalIndent(reply, "", " ") - if err != nil { - http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError) - return - } - w.Write(rep) - }) - mux.HandleFunc("/get_node_index", func(w http.ResponseWriter, req *http.Request) { - var request = new(GetNodeIndex) - b, err := ioutil.ReadAll(req.Body) - if err != nil { - http.Error(w, "read body failed", http.StatusBadRequest) - return - } - if err := json.Unmarshal(b, request); err != nil { - http.Error(w, "unmarshal data failed", http.StatusBadRequest) - return - } - reply, err := rpc.GetNodeIndex(req.Context(), request) - if err != nil { - http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError) - return - } - rep, err := json.MarshalIndent(reply, "", " ") - if err != nil { - http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError) - return - } - w.Write(rep) - }) - mux.HandleFunc("/show_threads", func(w http.ResponseWriter, req *http.Request) { - var request = new(ShowThreads) - reply, err := rpc.ShowThreads(req.Context(), request) - if err != nil { - http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError) - return - } - rep, err := json.MarshalIndent(reply, "", " ") - if err != nil { - http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError) - return - } - w.Write(rep) - }) mux.HandleFunc("/show_version", func(w http.ResponseWriter, req *http.Request) { var request = new(ShowVersion) reply, err := rpc.ShowVersion(req.Context(), request)