// Code generated by GoVPP's binapi-generator. DO NOT EDIT. package l3xc import ( "encoding/json" "io/ioutil" "net/http" ) func RESTHandler(rpc RPCService) http.Handler { mux := http.NewServeMux() mux.HandleFunc("/l3xc_del", func(w http.ResponseWriter, req *http.Request) { var request = new(L3xcDel) 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.L3xcDel(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("/l3xc_plugin_get_version", func(w http.ResponseWriter, req *http.Request) { var request = new(L3xcPluginGetVersion) reply, err := rpc.L3xcPluginGetVersion(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("/l3xc_update", func(w http.ResponseWriter, req *http.Request) { var request = new(L3xcUpdate) 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.L3xcUpdate(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) }