// 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) }