diff options
author | Vladimir Lavor <vlavor@cisco.com> | 2020-10-13 13:59:25 +0200 |
---|---|---|
committer | Vladimir Lavor <vlavor@cisco.com> | 2020-10-13 13:59:25 +0200 |
commit | 8d4ee12e94e634b38f1dc55c830f8e222822215f (patch) | |
tree | a83bbd7a9d18c2bda32ec9c34f769980094f050c /binapi/vpe | |
parent | 4cf5e5c04b9f9b10f9b370faf0f277ac210c4b62 (diff) |
Generate VPE HTTP handler
* This should fix GoVPP build
Change-Id: If53177253ad4a6616860aad50ce54e5944bbea6e
Signed-off-by: Vladimir Lavor <vlavor@cisco.com>
Diffstat (limited to 'binapi/vpe')
-rw-r--r-- | binapi/vpe/vpe_http.ba.go | 245 |
1 files changed, 245 insertions, 0 deletions
diff --git a/binapi/vpe/vpe_http.ba.go b/binapi/vpe/vpe_http.ba.go new file mode 100644 index 0000000..8998c9e --- /dev/null +++ b/binapi/vpe/vpe_http.ba.go @@ -0,0 +1,245 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +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) + 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_vpe_system_time", func(w http.ResponseWriter, req *http.Request) { + var request = new(ShowVpeSystemTime) + reply, err := rpc.ShowVpeSystemTime(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) + }) + return http.HandlerFunc(mux.ServeHTTP) +} |