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("/ioam_disable", func(w http.ResponseWriter, req *http.Request) {
14 var request = new(IoamDisable)
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.IoamDisable(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("/ioam_enable", func(w http.ResponseWriter, req *http.Request) {
37 var request = new(IoamEnable)
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.IoamEnable(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_container_proxy_add_del", func(w http.ResponseWriter, req *http.Request) {
60 var request = new(IPContainerProxyAddDel)
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.IPContainerProxyAddDel(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_mroute_add_del", func(w http.ResponseWriter, req *http.Request) {
83 var request = new(IPMrouteAddDel)
84 b, err := ioutil.ReadAll(req.Body)
86 http.Error(w, "read body failed", http.StatusBadRequest)
89 if err := json.Unmarshal(b, request); err != nil {
90 http.Error(w, "unmarshal data failed", http.StatusBadRequest)
93 reply, err := rpc.IPMrouteAddDel(req.Context(), request)
95 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
98 rep, err := json.MarshalIndent(reply, "", " ")
100 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
105 mux.HandleFunc("/ip_punt_police", func(w http.ResponseWriter, req *http.Request) {
106 var request = new(IPPuntPolice)
107 b, err := ioutil.ReadAll(req.Body)
109 http.Error(w, "read body failed", http.StatusBadRequest)
112 if err := json.Unmarshal(b, request); err != nil {
113 http.Error(w, "unmarshal data failed", http.StatusBadRequest)
116 reply, err := rpc.IPPuntPolice(req.Context(), request)
118 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
121 rep, err := json.MarshalIndent(reply, "", " ")
123 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
128 mux.HandleFunc("/ip_punt_redirect", func(w http.ResponseWriter, req *http.Request) {
129 var request = new(IPPuntRedirect)
130 b, err := ioutil.ReadAll(req.Body)
132 http.Error(w, "read body failed", http.StatusBadRequest)
135 if err := json.Unmarshal(b, request); err != nil {
136 http.Error(w, "unmarshal data failed", http.StatusBadRequest)
139 reply, err := rpc.IPPuntRedirect(req.Context(), request)
141 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
144 rep, err := json.MarshalIndent(reply, "", " ")
146 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
151 mux.HandleFunc("/ip_reassembly_enable_disable", func(w http.ResponseWriter, req *http.Request) {
152 var request = new(IPReassemblyEnableDisable)
153 b, err := ioutil.ReadAll(req.Body)
155 http.Error(w, "read body failed", http.StatusBadRequest)
158 if err := json.Unmarshal(b, request); err != nil {
159 http.Error(w, "unmarshal data failed", http.StatusBadRequest)
162 reply, err := rpc.IPReassemblyEnableDisable(req.Context(), request)
164 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
167 rep, err := json.MarshalIndent(reply, "", " ")
169 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
174 mux.HandleFunc("/ip_reassembly_get", func(w http.ResponseWriter, req *http.Request) {
175 var request = new(IPReassemblyGet)
176 b, err := ioutil.ReadAll(req.Body)
178 http.Error(w, "read body failed", http.StatusBadRequest)
181 if err := json.Unmarshal(b, request); err != nil {
182 http.Error(w, "unmarshal data failed", http.StatusBadRequest)
185 reply, err := rpc.IPReassemblyGet(req.Context(), request)
187 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
190 rep, err := json.MarshalIndent(reply, "", " ")
192 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
197 mux.HandleFunc("/ip_reassembly_set", func(w http.ResponseWriter, req *http.Request) {
198 var request = new(IPReassemblySet)
199 b, err := ioutil.ReadAll(req.Body)
201 http.Error(w, "read body failed", http.StatusBadRequest)
204 if err := json.Unmarshal(b, request); err != nil {
205 http.Error(w, "unmarshal data failed", http.StatusBadRequest)
208 reply, err := rpc.IPReassemblySet(req.Context(), request)
210 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
213 rep, err := json.MarshalIndent(reply, "", " ")
215 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
220 mux.HandleFunc("/ip_route_add_del", func(w http.ResponseWriter, req *http.Request) {
221 var request = new(IPRouteAddDel)
222 b, err := ioutil.ReadAll(req.Body)
224 http.Error(w, "read body failed", http.StatusBadRequest)
227 if err := json.Unmarshal(b, request); err != nil {
228 http.Error(w, "unmarshal data failed", http.StatusBadRequest)
231 reply, err := rpc.IPRouteAddDel(req.Context(), request)
233 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
236 rep, err := json.MarshalIndent(reply, "", " ")
238 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
243 mux.HandleFunc("/ip_route_lookup", func(w http.ResponseWriter, req *http.Request) {
244 var request = new(IPRouteLookup)
245 b, err := ioutil.ReadAll(req.Body)
247 http.Error(w, "read body failed", http.StatusBadRequest)
250 if err := json.Unmarshal(b, request); err != nil {
251 http.Error(w, "unmarshal data failed", http.StatusBadRequest)
254 reply, err := rpc.IPRouteLookup(req.Context(), request)
256 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
259 rep, err := json.MarshalIndent(reply, "", " ")
261 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
266 mux.HandleFunc("/ip_source_and_port_range_check_add_del", func(w http.ResponseWriter, req *http.Request) {
267 var request = new(IPSourceAndPortRangeCheckAddDel)
268 b, err := ioutil.ReadAll(req.Body)
270 http.Error(w, "read body failed", http.StatusBadRequest)
273 if err := json.Unmarshal(b, request); err != nil {
274 http.Error(w, "unmarshal data failed", http.StatusBadRequest)
277 reply, err := rpc.IPSourceAndPortRangeCheckAddDel(req.Context(), request)
279 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
282 rep, err := json.MarshalIndent(reply, "", " ")
284 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
289 mux.HandleFunc("/ip_source_and_port_range_check_interface_add_del", func(w http.ResponseWriter, req *http.Request) {
290 var request = new(IPSourceAndPortRangeCheckInterfaceAddDel)
291 b, err := ioutil.ReadAll(req.Body)
293 http.Error(w, "read body failed", http.StatusBadRequest)
296 if err := json.Unmarshal(b, request); err != nil {
297 http.Error(w, "unmarshal data failed", http.StatusBadRequest)
300 reply, err := rpc.IPSourceAndPortRangeCheckInterfaceAddDel(req.Context(), request)
302 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
305 rep, err := json.MarshalIndent(reply, "", " ")
307 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
312 mux.HandleFunc("/ip_table_add_del", func(w http.ResponseWriter, req *http.Request) {
313 var request = new(IPTableAddDel)
314 b, err := ioutil.ReadAll(req.Body)
316 http.Error(w, "read body failed", http.StatusBadRequest)
319 if err := json.Unmarshal(b, request); err != nil {
320 http.Error(w, "unmarshal data failed", http.StatusBadRequest)
323 reply, err := rpc.IPTableAddDel(req.Context(), request)
325 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
328 rep, err := json.MarshalIndent(reply, "", " ")
330 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
335 mux.HandleFunc("/ip_table_flush", func(w http.ResponseWriter, req *http.Request) {
336 var request = new(IPTableFlush)
337 b, err := ioutil.ReadAll(req.Body)
339 http.Error(w, "read body failed", http.StatusBadRequest)
342 if err := json.Unmarshal(b, request); err != nil {
343 http.Error(w, "unmarshal data failed", http.StatusBadRequest)
346 reply, err := rpc.IPTableFlush(req.Context(), request)
348 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
351 rep, err := json.MarshalIndent(reply, "", " ")
353 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
358 mux.HandleFunc("/ip_table_replace_begin", func(w http.ResponseWriter, req *http.Request) {
359 var request = new(IPTableReplaceBegin)
360 b, err := ioutil.ReadAll(req.Body)
362 http.Error(w, "read body failed", http.StatusBadRequest)
365 if err := json.Unmarshal(b, request); err != nil {
366 http.Error(w, "unmarshal data failed", http.StatusBadRequest)
369 reply, err := rpc.IPTableReplaceBegin(req.Context(), request)
371 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
374 rep, err := json.MarshalIndent(reply, "", " ")
376 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
381 mux.HandleFunc("/ip_table_replace_end", func(w http.ResponseWriter, req *http.Request) {
382 var request = new(IPTableReplaceEnd)
383 b, err := ioutil.ReadAll(req.Body)
385 http.Error(w, "read body failed", http.StatusBadRequest)
388 if err := json.Unmarshal(b, request); err != nil {
389 http.Error(w, "unmarshal data failed", http.StatusBadRequest)
392 reply, err := rpc.IPTableReplaceEnd(req.Context(), request)
394 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
397 rep, err := json.MarshalIndent(reply, "", " ")
399 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
404 mux.HandleFunc("/set_ip_flow_hash", func(w http.ResponseWriter, req *http.Request) {
405 var request = new(SetIPFlowHash)
406 b, err := ioutil.ReadAll(req.Body)
408 http.Error(w, "read body failed", http.StatusBadRequest)
411 if err := json.Unmarshal(b, request); err != nil {
412 http.Error(w, "unmarshal data failed", http.StatusBadRequest)
415 reply, err := rpc.SetIPFlowHash(req.Context(), request)
417 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
420 rep, err := json.MarshalIndent(reply, "", " ")
422 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
427 mux.HandleFunc("/sw_interface_ip6_enable_disable", func(w http.ResponseWriter, req *http.Request) {
428 var request = new(SwInterfaceIP6EnableDisable)
429 b, err := ioutil.ReadAll(req.Body)
431 http.Error(w, "read body failed", http.StatusBadRequest)
434 if err := json.Unmarshal(b, request); err != nil {
435 http.Error(w, "unmarshal data failed", http.StatusBadRequest)
438 reply, err := rpc.SwInterfaceIP6EnableDisable(req.Context(), request)
440 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
443 rep, err := json.MarshalIndent(reply, "", " ")
445 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
450 mux.HandleFunc("/sw_interface_ip6_set_link_local_address", func(w http.ResponseWriter, req *http.Request) {
451 var request = new(SwInterfaceIP6SetLinkLocalAddress)
452 b, err := ioutil.ReadAll(req.Body)
454 http.Error(w, "read body failed", http.StatusBadRequest)
457 if err := json.Unmarshal(b, request); err != nil {
458 http.Error(w, "unmarshal data failed", http.StatusBadRequest)
461 reply, err := rpc.SwInterfaceIP6SetLinkLocalAddress(req.Context(), request)
463 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
466 rep, err := json.MarshalIndent(reply, "", " ")
468 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
473 return http.HandlerFunc(mux.ServeHTTP)