Check retval value and convert to error in generated RPC client code
[govpp.git] / binapi / ip / ip_rest.ba.go
diff --git a/binapi/ip/ip_rest.ba.go b/binapi/ip/ip_rest.ba.go
deleted file mode 100644 (file)
index 245ffed..0000000
+++ /dev/null
@@ -1,474 +0,0 @@
-// Code generated by GoVPP's binapi-generator. DO NOT EDIT.
-
-package ip
-
-import (
-       "encoding/json"
-       "io/ioutil"
-       "net/http"
-)
-
-func RESTHandler(rpc RPCService) http.Handler {
-       mux := http.NewServeMux()
-       mux.HandleFunc("/ioam_disable", func(w http.ResponseWriter, req *http.Request) {
-               var request = new(IoamDisable)
-               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.IoamDisable(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("/ioam_enable", func(w http.ResponseWriter, req *http.Request) {
-               var request = new(IoamEnable)
-               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.IoamEnable(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("/ip_container_proxy_add_del", func(w http.ResponseWriter, req *http.Request) {
-               var request = new(IPContainerProxyAddDel)
-               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.IPContainerProxyAddDel(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("/ip_mroute_add_del", func(w http.ResponseWriter, req *http.Request) {
-               var request = new(IPMrouteAddDel)
-               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.IPMrouteAddDel(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("/ip_punt_police", func(w http.ResponseWriter, req *http.Request) {
-               var request = new(IPPuntPolice)
-               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.IPPuntPolice(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("/ip_punt_redirect", func(w http.ResponseWriter, req *http.Request) {
-               var request = new(IPPuntRedirect)
-               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.IPPuntRedirect(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("/ip_reassembly_enable_disable", func(w http.ResponseWriter, req *http.Request) {
-               var request = new(IPReassemblyEnableDisable)
-               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.IPReassemblyEnableDisable(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("/ip_reassembly_get", func(w http.ResponseWriter, req *http.Request) {
-               var request = new(IPReassemblyGet)
-               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.IPReassemblyGet(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("/ip_reassembly_set", func(w http.ResponseWriter, req *http.Request) {
-               var request = new(IPReassemblySet)
-               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.IPReassemblySet(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("/ip_route_add_del", func(w http.ResponseWriter, req *http.Request) {
-               var request = new(IPRouteAddDel)
-               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.IPRouteAddDel(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("/ip_route_lookup", func(w http.ResponseWriter, req *http.Request) {
-               var request = new(IPRouteLookup)
-               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.IPRouteLookup(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("/ip_source_and_port_range_check_add_del", func(w http.ResponseWriter, req *http.Request) {
-               var request = new(IPSourceAndPortRangeCheckAddDel)
-               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.IPSourceAndPortRangeCheckAddDel(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("/ip_source_and_port_range_check_interface_add_del", func(w http.ResponseWriter, req *http.Request) {
-               var request = new(IPSourceAndPortRangeCheckInterfaceAddDel)
-               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.IPSourceAndPortRangeCheckInterfaceAddDel(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("/ip_table_add_del", func(w http.ResponseWriter, req *http.Request) {
-               var request = new(IPTableAddDel)
-               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.IPTableAddDel(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("/ip_table_flush", func(w http.ResponseWriter, req *http.Request) {
-               var request = new(IPTableFlush)
-               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.IPTableFlush(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("/ip_table_replace_begin", func(w http.ResponseWriter, req *http.Request) {
-               var request = new(IPTableReplaceBegin)
-               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.IPTableReplaceBegin(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("/ip_table_replace_end", func(w http.ResponseWriter, req *http.Request) {
-               var request = new(IPTableReplaceEnd)
-               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.IPTableReplaceEnd(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("/set_ip_flow_hash", func(w http.ResponseWriter, req *http.Request) {
-               var request = new(SetIPFlowHash)
-               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.SetIPFlowHash(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("/sw_interface_ip6_enable_disable", func(w http.ResponseWriter, req *http.Request) {
-               var request = new(SwInterfaceIP6EnableDisable)
-               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.SwInterfaceIP6EnableDisable(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("/sw_interface_ip6_set_link_local_address", func(w http.ResponseWriter, req *http.Request) {
-               var request = new(SwInterfaceIP6SetLinkLocalAddress)
-               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.SwInterfaceIP6SetLinkLocalAddress(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)
-}