Improve binapi generator
[govpp.git] / binapi / bier / bier_rest.ba.go
diff --git a/binapi/bier/bier_rest.ba.go b/binapi/bier/bier_rest.ba.go
new file mode 100644 (file)
index 0000000..f65f8f3
--- /dev/null
@@ -0,0 +1,152 @@
+// Code generated by GoVPP's binapi-generator. DO NOT EDIT.
+
+package bier
+
+import (
+       "encoding/json"
+       "io/ioutil"
+       "net/http"
+)
+
+func RESTHandler(rpc RPCService) http.Handler {
+       mux := http.NewServeMux()
+       mux.HandleFunc("/bier_disp_entry_add_del", func(w http.ResponseWriter, req *http.Request) {
+               var request = new(BierDispEntryAddDel)
+               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.BierDispEntryAddDel(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("/bier_disp_table_add_del", func(w http.ResponseWriter, req *http.Request) {
+               var request = new(BierDispTableAddDel)
+               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.BierDispTableAddDel(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("/bier_imp_add", func(w http.ResponseWriter, req *http.Request) {
+               var request = new(BierImpAdd)
+               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.BierImpAdd(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("/bier_imp_del", func(w http.ResponseWriter, req *http.Request) {
+               var request = new(BierImpDel)
+               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.BierImpDel(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("/bier_route_add_del", func(w http.ResponseWriter, req *http.Request) {
+               var request = new(BierRouteAddDel)
+               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.BierRouteAddDel(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("/bier_table_add_del", func(w http.ResponseWriter, req *http.Request) {
+               var request = new(BierTableAddDel)
+               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.BierTableAddDel(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)
+}