// Code generated by GoVPP's binapi-generator. DO NOT EDIT. package ipip import ( "encoding/json" "io/ioutil" "net/http" ) func RESTHandler(rpc RPCService) http.Handler { mux := http.NewServeMux() mux.HandleFunc("/ipip_6rd_add_tunnel", func(w http.ResponseWriter, req *http.Request) { var request = new(Ipip6rdAddTunnel) 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.Ipip6rdAddTunnel(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("/ipip_6rd_del_tunnel", func(w http.ResponseWriter, req *http.Request) { var request = new(Ipip6rdDelTunnel) 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.Ipip6rdDelTunnel(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("/ipip_add_tunnel", func(w http.ResponseWriter, req *http.Request) { var request = new(IpipAddTunnel) 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.IpipAddTunnel(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("/ipip_del_tunnel", func(w http.ResponseWriter, req *http.Request) { var request = new(IpipDelTunnel) 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.IpipDelTunnel(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) }