// Code generated by GoVPP's binapi-generator. DO NOT EDIT. package mpls import ( "encoding/json" "io/ioutil" "net/http" ) func RESTHandler(rpc RPCService) http.Handler { mux := http.NewServeMux() mux.HandleFunc("/mpls_ip_bind_unbind", func(w http.ResponseWriter, req *http.Request) { var request = new(MplsIPBindUnbind) 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.MplsIPBindUnbind(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("/mpls_route_add_del", func(w http.ResponseWriter, req *http.Request) { var request = new(MplsRouteAddDel) 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.MplsRouteAddDel(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("/mpls_table_add_del", func(w http.ResponseWriter, req *http.Request) { var request = new(MplsTableAddDel) 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.MplsTableAddDel(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("/mpls_tunnel_add_del", func(w http.ResponseWriter, req *http.Request) { var request = new(MplsTunnelAddDel) 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.MplsTunnelAddDel(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_set_mpls_enable", func(w http.ResponseWriter, req *http.Request) { var request = new(SwInterfaceSetMplsEnable) 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.SwInterfaceSetMplsEnable(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) }