Updated changelog for v0.4.0
[govpp.git] / binapi / ip_neighbor / ip_neighbor_rest.ba.go
1 // Code generated by GoVPP's binapi-generator. DO NOT EDIT.
2
3 package ip_neighbor
4
5 import (
6         "encoding/json"
7         "io/ioutil"
8         "net/http"
9 )
10
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)
16                 if err != nil {
17                         http.Error(w, "read body failed", http.StatusBadRequest)
18                         return
19                 }
20                 if err := json.Unmarshal(b, request); err != nil {
21                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
22                         return
23                 }
24                 reply, err := rpc.IPNeighborAddDel(req.Context(), request)
25                 if err != nil {
26                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
27                         return
28                 }
29                 rep, err := json.MarshalIndent(reply, "", "  ")
30                 if err != nil {
31                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
32                         return
33                 }
34                 w.Write(rep)
35         })
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)
39                 if err != nil {
40                         http.Error(w, "read body failed", http.StatusBadRequest)
41                         return
42                 }
43                 if err := json.Unmarshal(b, request); err != nil {
44                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
45                         return
46                 }
47                 reply, err := rpc.IPNeighborConfig(req.Context(), request)
48                 if err != nil {
49                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
50                         return
51                 }
52                 rep, err := json.MarshalIndent(reply, "", "  ")
53                 if err != nil {
54                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
55                         return
56                 }
57                 w.Write(rep)
58         })
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)
62                 if err != nil {
63                         http.Error(w, "read body failed", http.StatusBadRequest)
64                         return
65                 }
66                 if err := json.Unmarshal(b, request); err != nil {
67                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
68                         return
69                 }
70                 reply, err := rpc.IPNeighborFlush(req.Context(), request)
71                 if err != nil {
72                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
73                         return
74                 }
75                 rep, err := json.MarshalIndent(reply, "", "  ")
76                 if err != nil {
77                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
78                         return
79                 }
80                 w.Write(rep)
81         })
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)
85                 if err != nil {
86                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
87                         return
88                 }
89                 rep, err := json.MarshalIndent(reply, "", "  ")
90                 if err != nil {
91                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
92                         return
93                 }
94                 w.Write(rep)
95         })
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)
99                 if err != nil {
100                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
101                         return
102                 }
103                 rep, err := json.MarshalIndent(reply, "", "  ")
104                 if err != nil {
105                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
106                         return
107                 }
108                 w.Write(rep)
109         })
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)
113                 if err != nil {
114                         http.Error(w, "read body failed", http.StatusBadRequest)
115                         return
116                 }
117                 if err := json.Unmarshal(b, request); err != nil {
118                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
119                         return
120                 }
121                 reply, err := rpc.WantIPNeighborEvents(req.Context(), request)
122                 if err != nil {
123                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
124                         return
125                 }
126                 rep, err := json.MarshalIndent(reply, "", "  ")
127                 if err != nil {
128                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
129                         return
130                 }
131                 w.Write(rep)
132         })
133         return http.HandlerFunc(mux.ServeHTTP)
134 }