Updated changelog for v0.4.0
[govpp.git] / binapi / classify / classify_rest.ba.go
1 // Code generated by GoVPP's binapi-generator. DO NOT EDIT.
2
3 package classify
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("/classify_add_del_session", func(w http.ResponseWriter, req *http.Request) {
14                 var request = new(ClassifyAddDelSession)
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.ClassifyAddDelSession(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("/classify_add_del_table", func(w http.ResponseWriter, req *http.Request) {
37                 var request = new(ClassifyAddDelTable)
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.ClassifyAddDelTable(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("/classify_set_interface_ip_table", func(w http.ResponseWriter, req *http.Request) {
60                 var request = new(ClassifySetInterfaceIPTable)
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.ClassifySetInterfaceIPTable(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("/classify_set_interface_l2_tables", func(w http.ResponseWriter, req *http.Request) {
83                 var request = new(ClassifySetInterfaceL2Tables)
84                 b, err := ioutil.ReadAll(req.Body)
85                 if err != nil {
86                         http.Error(w, "read body failed", http.StatusBadRequest)
87                         return
88                 }
89                 if err := json.Unmarshal(b, request); err != nil {
90                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
91                         return
92                 }
93                 reply, err := rpc.ClassifySetInterfaceL2Tables(req.Context(), request)
94                 if err != nil {
95                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
96                         return
97                 }
98                 rep, err := json.MarshalIndent(reply, "", "  ")
99                 if err != nil {
100                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
101                         return
102                 }
103                 w.Write(rep)
104         })
105         mux.HandleFunc("/classify_table_by_interface", func(w http.ResponseWriter, req *http.Request) {
106                 var request = new(ClassifyTableByInterface)
107                 b, err := ioutil.ReadAll(req.Body)
108                 if err != nil {
109                         http.Error(w, "read body failed", http.StatusBadRequest)
110                         return
111                 }
112                 if err := json.Unmarshal(b, request); err != nil {
113                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
114                         return
115                 }
116                 reply, err := rpc.ClassifyTableByInterface(req.Context(), request)
117                 if err != nil {
118                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
119                         return
120                 }
121                 rep, err := json.MarshalIndent(reply, "", "  ")
122                 if err != nil {
123                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
124                         return
125                 }
126                 w.Write(rep)
127         })
128         mux.HandleFunc("/classify_table_ids", func(w http.ResponseWriter, req *http.Request) {
129                 var request = new(ClassifyTableIds)
130                 reply, err := rpc.ClassifyTableIds(req.Context(), request)
131                 if err != nil {
132                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
133                         return
134                 }
135                 rep, err := json.MarshalIndent(reply, "", "  ")
136                 if err != nil {
137                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
138                         return
139                 }
140                 w.Write(rep)
141         })
142         mux.HandleFunc("/classify_table_info", func(w http.ResponseWriter, req *http.Request) {
143                 var request = new(ClassifyTableInfo)
144                 b, err := ioutil.ReadAll(req.Body)
145                 if err != nil {
146                         http.Error(w, "read body failed", http.StatusBadRequest)
147                         return
148                 }
149                 if err := json.Unmarshal(b, request); err != nil {
150                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
151                         return
152                 }
153                 reply, err := rpc.ClassifyTableInfo(req.Context(), request)
154                 if err != nil {
155                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
156                         return
157                 }
158                 rep, err := json.MarshalIndent(reply, "", "  ")
159                 if err != nil {
160                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
161                         return
162                 }
163                 w.Write(rep)
164         })
165         mux.HandleFunc("/flow_classify_set_interface", func(w http.ResponseWriter, req *http.Request) {
166                 var request = new(FlowClassifySetInterface)
167                 b, err := ioutil.ReadAll(req.Body)
168                 if err != nil {
169                         http.Error(w, "read body failed", http.StatusBadRequest)
170                         return
171                 }
172                 if err := json.Unmarshal(b, request); err != nil {
173                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
174                         return
175                 }
176                 reply, err := rpc.FlowClassifySetInterface(req.Context(), request)
177                 if err != nil {
178                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
179                         return
180                 }
181                 rep, err := json.MarshalIndent(reply, "", "  ")
182                 if err != nil {
183                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
184                         return
185                 }
186                 w.Write(rep)
187         })
188         mux.HandleFunc("/input_acl_set_interface", func(w http.ResponseWriter, req *http.Request) {
189                 var request = new(InputACLSetInterface)
190                 b, err := ioutil.ReadAll(req.Body)
191                 if err != nil {
192                         http.Error(w, "read body failed", http.StatusBadRequest)
193                         return
194                 }
195                 if err := json.Unmarshal(b, request); err != nil {
196                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
197                         return
198                 }
199                 reply, err := rpc.InputACLSetInterface(req.Context(), request)
200                 if err != nil {
201                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
202                         return
203                 }
204                 rep, err := json.MarshalIndent(reply, "", "  ")
205                 if err != nil {
206                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
207                         return
208                 }
209                 w.Write(rep)
210         })
211         mux.HandleFunc("/output_acl_set_interface", func(w http.ResponseWriter, req *http.Request) {
212                 var request = new(OutputACLSetInterface)
213                 b, err := ioutil.ReadAll(req.Body)
214                 if err != nil {
215                         http.Error(w, "read body failed", http.StatusBadRequest)
216                         return
217                 }
218                 if err := json.Unmarshal(b, request); err != nil {
219                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
220                         return
221                 }
222                 reply, err := rpc.OutputACLSetInterface(req.Context(), request)
223                 if err != nil {
224                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
225                         return
226                 }
227                 rep, err := json.MarshalIndent(reply, "", "  ")
228                 if err != nil {
229                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
230                         return
231                 }
232                 w.Write(rep)
233         })
234         mux.HandleFunc("/policer_classify_set_interface", func(w http.ResponseWriter, req *http.Request) {
235                 var request = new(PolicerClassifySetInterface)
236                 b, err := ioutil.ReadAll(req.Body)
237                 if err != nil {
238                         http.Error(w, "read body failed", http.StatusBadRequest)
239                         return
240                 }
241                 if err := json.Unmarshal(b, request); err != nil {
242                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
243                         return
244                 }
245                 reply, err := rpc.PolicerClassifySetInterface(req.Context(), request)
246                 if err != nil {
247                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
248                         return
249                 }
250                 rep, err := json.MarshalIndent(reply, "", "  ")
251                 if err != nil {
252                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
253                         return
254                 }
255                 w.Write(rep)
256         })
257         return http.HandlerFunc(mux.ServeHTTP)
258 }