1 // Code generated by GoVPP's binapi-generator. DO NOT EDIT.
11 func RESTHandler(rpc RPCService) http.Handler {
12 mux := http.NewServeMux()
13 mux.HandleFunc("/ip_neighbor_add_del", func(w http.ResponseWriter, req *http.Request) {
14 var request = new(IPNeighborAddDel)
15 b, err := ioutil.ReadAll(req.Body)
17 http.Error(w, "read body failed", http.StatusBadRequest)
20 if err := json.Unmarshal(b, request); err != nil {
21 http.Error(w, "unmarshal data failed", http.StatusBadRequest)
24 reply, err := rpc.IPNeighborAddDel(req.Context(), request)
26 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
29 rep, err := json.MarshalIndent(reply, "", " ")
31 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
36 mux.HandleFunc("/ip_neighbor_config", func(w http.ResponseWriter, req *http.Request) {
37 var request = new(IPNeighborConfig)
38 b, err := ioutil.ReadAll(req.Body)
40 http.Error(w, "read body failed", http.StatusBadRequest)
43 if err := json.Unmarshal(b, request); err != nil {
44 http.Error(w, "unmarshal data failed", http.StatusBadRequest)
47 reply, err := rpc.IPNeighborConfig(req.Context(), request)
49 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
52 rep, err := json.MarshalIndent(reply, "", " ")
54 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
59 mux.HandleFunc("/ip_neighbor_flush", func(w http.ResponseWriter, req *http.Request) {
60 var request = new(IPNeighborFlush)
61 b, err := ioutil.ReadAll(req.Body)
63 http.Error(w, "read body failed", http.StatusBadRequest)
66 if err := json.Unmarshal(b, request); err != nil {
67 http.Error(w, "unmarshal data failed", http.StatusBadRequest)
70 reply, err := rpc.IPNeighborFlush(req.Context(), request)
72 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
75 rep, err := json.MarshalIndent(reply, "", " ")
77 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
82 mux.HandleFunc("/ip_neighbor_replace_begin", func(w http.ResponseWriter, req *http.Request) {
83 var request = new(IPNeighborReplaceBegin)
84 reply, err := rpc.IPNeighborReplaceBegin(req.Context(), request)
86 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
89 rep, err := json.MarshalIndent(reply, "", " ")
91 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
96 mux.HandleFunc("/ip_neighbor_replace_end", func(w http.ResponseWriter, req *http.Request) {
97 var request = new(IPNeighborReplaceEnd)
98 reply, err := rpc.IPNeighborReplaceEnd(req.Context(), request)
100 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
103 rep, err := json.MarshalIndent(reply, "", " ")
105 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
110 mux.HandleFunc("/want_ip_neighbor_events", func(w http.ResponseWriter, req *http.Request) {
111 var request = new(WantIPNeighborEvents)
112 b, err := ioutil.ReadAll(req.Body)
114 http.Error(w, "read body failed", http.StatusBadRequest)
117 if err := json.Unmarshal(b, request); err != nil {
118 http.Error(w, "unmarshal data failed", http.StatusBadRequest)
121 reply, err := rpc.WantIPNeighborEvents(req.Context(), request)
123 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
126 rep, err := json.MarshalIndent(reply, "", " ")
128 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
133 return http.HandlerFunc(mux.ServeHTTP)