7740ea1b8233b7b457b444effdb25bde30818cd0
[govpp.git] / binapi / nat / nat_rest.ba.go
1 // Code generated by GoVPP's binapi-generator. DO NOT EDIT.
2
3 package nat
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("/nat44_add_del_address_range", func(w http.ResponseWriter, req *http.Request) {
14                 var request = new(Nat44AddDelAddressRange)
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.Nat44AddDelAddressRange(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("/nat44_add_del_identity_mapping", func(w http.ResponseWriter, req *http.Request) {
37                 var request = new(Nat44AddDelIdentityMapping)
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.Nat44AddDelIdentityMapping(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("/nat44_add_del_interface_addr", func(w http.ResponseWriter, req *http.Request) {
60                 var request = new(Nat44AddDelInterfaceAddr)
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.Nat44AddDelInterfaceAddr(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("/nat44_add_del_lb_static_mapping", func(w http.ResponseWriter, req *http.Request) {
83                 var request = new(Nat44AddDelLbStaticMapping)
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.Nat44AddDelLbStaticMapping(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("/nat44_add_del_static_mapping", func(w http.ResponseWriter, req *http.Request) {
106                 var request = new(Nat44AddDelStaticMapping)
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.Nat44AddDelStaticMapping(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("/nat44_del_session", func(w http.ResponseWriter, req *http.Request) {
129                 var request = new(Nat44DelSession)
130                 b, err := ioutil.ReadAll(req.Body)
131                 if err != nil {
132                         http.Error(w, "read body failed", http.StatusBadRequest)
133                         return
134                 }
135                 if err := json.Unmarshal(b, request); err != nil {
136                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
137                         return
138                 }
139                 reply, err := rpc.Nat44DelSession(req.Context(), request)
140                 if err != nil {
141                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
142                         return
143                 }
144                 rep, err := json.MarshalIndent(reply, "", "  ")
145                 if err != nil {
146                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
147                         return
148                 }
149                 w.Write(rep)
150         })
151         mux.HandleFunc("/nat44_del_user", func(w http.ResponseWriter, req *http.Request) {
152                 var request = new(Nat44DelUser)
153                 b, err := ioutil.ReadAll(req.Body)
154                 if err != nil {
155                         http.Error(w, "read body failed", http.StatusBadRequest)
156                         return
157                 }
158                 if err := json.Unmarshal(b, request); err != nil {
159                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
160                         return
161                 }
162                 reply, err := rpc.Nat44DelUser(req.Context(), request)
163                 if err != nil {
164                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
165                         return
166                 }
167                 rep, err := json.MarshalIndent(reply, "", "  ")
168                 if err != nil {
169                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
170                         return
171                 }
172                 w.Write(rep)
173         })
174         mux.HandleFunc("/nat44_forwarding_enable_disable", func(w http.ResponseWriter, req *http.Request) {
175                 var request = new(Nat44ForwardingEnableDisable)
176                 b, err := ioutil.ReadAll(req.Body)
177                 if err != nil {
178                         http.Error(w, "read body failed", http.StatusBadRequest)
179                         return
180                 }
181                 if err := json.Unmarshal(b, request); err != nil {
182                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
183                         return
184                 }
185                 reply, err := rpc.Nat44ForwardingEnableDisable(req.Context(), request)
186                 if err != nil {
187                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
188                         return
189                 }
190                 rep, err := json.MarshalIndent(reply, "", "  ")
191                 if err != nil {
192                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
193                         return
194                 }
195                 w.Write(rep)
196         })
197         mux.HandleFunc("/nat44_forwarding_is_enabled", func(w http.ResponseWriter, req *http.Request) {
198                 var request = new(Nat44ForwardingIsEnabled)
199                 reply, err := rpc.Nat44ForwardingIsEnabled(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("/nat44_interface_add_del_feature", func(w http.ResponseWriter, req *http.Request) {
212                 var request = new(Nat44InterfaceAddDelFeature)
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.Nat44InterfaceAddDelFeature(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("/nat44_interface_add_del_output_feature", func(w http.ResponseWriter, req *http.Request) {
235                 var request = new(Nat44InterfaceAddDelOutputFeature)
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.Nat44InterfaceAddDelOutputFeature(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         mux.HandleFunc("/nat44_lb_static_mapping_add_del_local", func(w http.ResponseWriter, req *http.Request) {
258                 var request = new(Nat44LbStaticMappingAddDelLocal)
259                 b, err := ioutil.ReadAll(req.Body)
260                 if err != nil {
261                         http.Error(w, "read body failed", http.StatusBadRequest)
262                         return
263                 }
264                 if err := json.Unmarshal(b, request); err != nil {
265                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
266                         return
267                 }
268                 reply, err := rpc.Nat44LbStaticMappingAddDelLocal(req.Context(), request)
269                 if err != nil {
270                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
271                         return
272                 }
273                 rep, err := json.MarshalIndent(reply, "", "  ")
274                 if err != nil {
275                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
276                         return
277                 }
278                 w.Write(rep)
279         })
280         mux.HandleFunc("/nat44_session_cleanup", func(w http.ResponseWriter, req *http.Request) {
281                 var request = new(Nat44SessionCleanup)
282                 reply, err := rpc.Nat44SessionCleanup(req.Context(), request)
283                 if err != nil {
284                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
285                         return
286                 }
287                 rep, err := json.MarshalIndent(reply, "", "  ")
288                 if err != nil {
289                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
290                         return
291                 }
292                 w.Write(rep)
293         })
294         mux.HandleFunc("/nat44_set_session_limit", func(w http.ResponseWriter, req *http.Request) {
295                 var request = new(Nat44SetSessionLimit)
296                 b, err := ioutil.ReadAll(req.Body)
297                 if err != nil {
298                         http.Error(w, "read body failed", http.StatusBadRequest)
299                         return
300                 }
301                 if err := json.Unmarshal(b, request); err != nil {
302                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
303                         return
304                 }
305                 reply, err := rpc.Nat44SetSessionLimit(req.Context(), request)
306                 if err != nil {
307                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
308                         return
309                 }
310                 rep, err := json.MarshalIndent(reply, "", "  ")
311                 if err != nil {
312                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
313                         return
314                 }
315                 w.Write(rep)
316         })
317         mux.HandleFunc("/nat64_add_del_interface", func(w http.ResponseWriter, req *http.Request) {
318                 var request = new(Nat64AddDelInterface)
319                 b, err := ioutil.ReadAll(req.Body)
320                 if err != nil {
321                         http.Error(w, "read body failed", http.StatusBadRequest)
322                         return
323                 }
324                 if err := json.Unmarshal(b, request); err != nil {
325                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
326                         return
327                 }
328                 reply, err := rpc.Nat64AddDelInterface(req.Context(), request)
329                 if err != nil {
330                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
331                         return
332                 }
333                 rep, err := json.MarshalIndent(reply, "", "  ")
334                 if err != nil {
335                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
336                         return
337                 }
338                 w.Write(rep)
339         })
340         mux.HandleFunc("/nat64_add_del_interface_addr", func(w http.ResponseWriter, req *http.Request) {
341                 var request = new(Nat64AddDelInterfaceAddr)
342                 b, err := ioutil.ReadAll(req.Body)
343                 if err != nil {
344                         http.Error(w, "read body failed", http.StatusBadRequest)
345                         return
346                 }
347                 if err := json.Unmarshal(b, request); err != nil {
348                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
349                         return
350                 }
351                 reply, err := rpc.Nat64AddDelInterfaceAddr(req.Context(), request)
352                 if err != nil {
353                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
354                         return
355                 }
356                 rep, err := json.MarshalIndent(reply, "", "  ")
357                 if err != nil {
358                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
359                         return
360                 }
361                 w.Write(rep)
362         })
363         mux.HandleFunc("/nat64_add_del_pool_addr_range", func(w http.ResponseWriter, req *http.Request) {
364                 var request = new(Nat64AddDelPoolAddrRange)
365                 b, err := ioutil.ReadAll(req.Body)
366                 if err != nil {
367                         http.Error(w, "read body failed", http.StatusBadRequest)
368                         return
369                 }
370                 if err := json.Unmarshal(b, request); err != nil {
371                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
372                         return
373                 }
374                 reply, err := rpc.Nat64AddDelPoolAddrRange(req.Context(), request)
375                 if err != nil {
376                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
377                         return
378                 }
379                 rep, err := json.MarshalIndent(reply, "", "  ")
380                 if err != nil {
381                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
382                         return
383                 }
384                 w.Write(rep)
385         })
386         mux.HandleFunc("/nat64_add_del_prefix", func(w http.ResponseWriter, req *http.Request) {
387                 var request = new(Nat64AddDelPrefix)
388                 b, err := ioutil.ReadAll(req.Body)
389                 if err != nil {
390                         http.Error(w, "read body failed", http.StatusBadRequest)
391                         return
392                 }
393                 if err := json.Unmarshal(b, request); err != nil {
394                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
395                         return
396                 }
397                 reply, err := rpc.Nat64AddDelPrefix(req.Context(), request)
398                 if err != nil {
399                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
400                         return
401                 }
402                 rep, err := json.MarshalIndent(reply, "", "  ")
403                 if err != nil {
404                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
405                         return
406                 }
407                 w.Write(rep)
408         })
409         mux.HandleFunc("/nat64_add_del_static_bib", func(w http.ResponseWriter, req *http.Request) {
410                 var request = new(Nat64AddDelStaticBib)
411                 b, err := ioutil.ReadAll(req.Body)
412                 if err != nil {
413                         http.Error(w, "read body failed", http.StatusBadRequest)
414                         return
415                 }
416                 if err := json.Unmarshal(b, request); err != nil {
417                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
418                         return
419                 }
420                 reply, err := rpc.Nat64AddDelStaticBib(req.Context(), request)
421                 if err != nil {
422                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
423                         return
424                 }
425                 rep, err := json.MarshalIndent(reply, "", "  ")
426                 if err != nil {
427                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
428                         return
429                 }
430                 w.Write(rep)
431         })
432         mux.HandleFunc("/nat66_add_del_interface", func(w http.ResponseWriter, req *http.Request) {
433                 var request = new(Nat66AddDelInterface)
434                 b, err := ioutil.ReadAll(req.Body)
435                 if err != nil {
436                         http.Error(w, "read body failed", http.StatusBadRequest)
437                         return
438                 }
439                 if err := json.Unmarshal(b, request); err != nil {
440                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
441                         return
442                 }
443                 reply, err := rpc.Nat66AddDelInterface(req.Context(), request)
444                 if err != nil {
445                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
446                         return
447                 }
448                 rep, err := json.MarshalIndent(reply, "", "  ")
449                 if err != nil {
450                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
451                         return
452                 }
453                 w.Write(rep)
454         })
455         mux.HandleFunc("/nat66_add_del_static_mapping", func(w http.ResponseWriter, req *http.Request) {
456                 var request = new(Nat66AddDelStaticMapping)
457                 b, err := ioutil.ReadAll(req.Body)
458                 if err != nil {
459                         http.Error(w, "read body failed", http.StatusBadRequest)
460                         return
461                 }
462                 if err := json.Unmarshal(b, request); err != nil {
463                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
464                         return
465                 }
466                 reply, err := rpc.Nat66AddDelStaticMapping(req.Context(), request)
467                 if err != nil {
468                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
469                         return
470                 }
471                 rep, err := json.MarshalIndent(reply, "", "  ")
472                 if err != nil {
473                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
474                         return
475                 }
476                 w.Write(rep)
477         })
478         mux.HandleFunc("/nat_control_ping", func(w http.ResponseWriter, req *http.Request) {
479                 var request = new(NatControlPing)
480                 reply, err := rpc.NatControlPing(req.Context(), request)
481                 if err != nil {
482                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
483                         return
484                 }
485                 rep, err := json.MarshalIndent(reply, "", "  ")
486                 if err != nil {
487                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
488                         return
489                 }
490                 w.Write(rep)
491         })
492         mux.HandleFunc("/nat_det_add_del_map", func(w http.ResponseWriter, req *http.Request) {
493                 var request = new(NatDetAddDelMap)
494                 b, err := ioutil.ReadAll(req.Body)
495                 if err != nil {
496                         http.Error(w, "read body failed", http.StatusBadRequest)
497                         return
498                 }
499                 if err := json.Unmarshal(b, request); err != nil {
500                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
501                         return
502                 }
503                 reply, err := rpc.NatDetAddDelMap(req.Context(), request)
504                 if err != nil {
505                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
506                         return
507                 }
508                 rep, err := json.MarshalIndent(reply, "", "  ")
509                 if err != nil {
510                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
511                         return
512                 }
513                 w.Write(rep)
514         })
515         mux.HandleFunc("/nat_det_close_session_in", func(w http.ResponseWriter, req *http.Request) {
516                 var request = new(NatDetCloseSessionIn)
517                 b, err := ioutil.ReadAll(req.Body)
518                 if err != nil {
519                         http.Error(w, "read body failed", http.StatusBadRequest)
520                         return
521                 }
522                 if err := json.Unmarshal(b, request); err != nil {
523                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
524                         return
525                 }
526                 reply, err := rpc.NatDetCloseSessionIn(req.Context(), request)
527                 if err != nil {
528                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
529                         return
530                 }
531                 rep, err := json.MarshalIndent(reply, "", "  ")
532                 if err != nil {
533                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
534                         return
535                 }
536                 w.Write(rep)
537         })
538         mux.HandleFunc("/nat_det_close_session_out", func(w http.ResponseWriter, req *http.Request) {
539                 var request = new(NatDetCloseSessionOut)
540                 b, err := ioutil.ReadAll(req.Body)
541                 if err != nil {
542                         http.Error(w, "read body failed", http.StatusBadRequest)
543                         return
544                 }
545                 if err := json.Unmarshal(b, request); err != nil {
546                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
547                         return
548                 }
549                 reply, err := rpc.NatDetCloseSessionOut(req.Context(), request)
550                 if err != nil {
551                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
552                         return
553                 }
554                 rep, err := json.MarshalIndent(reply, "", "  ")
555                 if err != nil {
556                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
557                         return
558                 }
559                 w.Write(rep)
560         })
561         mux.HandleFunc("/nat_det_forward", func(w http.ResponseWriter, req *http.Request) {
562                 var request = new(NatDetForward)
563                 b, err := ioutil.ReadAll(req.Body)
564                 if err != nil {
565                         http.Error(w, "read body failed", http.StatusBadRequest)
566                         return
567                 }
568                 if err := json.Unmarshal(b, request); err != nil {
569                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
570                         return
571                 }
572                 reply, err := rpc.NatDetForward(req.Context(), request)
573                 if err != nil {
574                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
575                         return
576                 }
577                 rep, err := json.MarshalIndent(reply, "", "  ")
578                 if err != nil {
579                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
580                         return
581                 }
582                 w.Write(rep)
583         })
584         mux.HandleFunc("/nat_det_reverse", func(w http.ResponseWriter, req *http.Request) {
585                 var request = new(NatDetReverse)
586                 b, err := ioutil.ReadAll(req.Body)
587                 if err != nil {
588                         http.Error(w, "read body failed", http.StatusBadRequest)
589                         return
590                 }
591                 if err := json.Unmarshal(b, request); err != nil {
592                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
593                         return
594                 }
595                 reply, err := rpc.NatDetReverse(req.Context(), request)
596                 if err != nil {
597                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
598                         return
599                 }
600                 rep, err := json.MarshalIndent(reply, "", "  ")
601                 if err != nil {
602                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
603                         return
604                 }
605                 w.Write(rep)
606         })
607         mux.HandleFunc("/nat_get_addr_and_port_alloc_alg", func(w http.ResponseWriter, req *http.Request) {
608                 var request = new(NatGetAddrAndPortAllocAlg)
609                 reply, err := rpc.NatGetAddrAndPortAllocAlg(req.Context(), request)
610                 if err != nil {
611                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
612                         return
613                 }
614                 rep, err := json.MarshalIndent(reply, "", "  ")
615                 if err != nil {
616                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
617                         return
618                 }
619                 w.Write(rep)
620         })
621         mux.HandleFunc("/nat_get_mss_clamping", func(w http.ResponseWriter, req *http.Request) {
622                 var request = new(NatGetMssClamping)
623                 reply, err := rpc.NatGetMssClamping(req.Context(), request)
624                 if err != nil {
625                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
626                         return
627                 }
628                 rep, err := json.MarshalIndent(reply, "", "  ")
629                 if err != nil {
630                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
631                         return
632                 }
633                 w.Write(rep)
634         })
635         mux.HandleFunc("/nat_get_timeouts", func(w http.ResponseWriter, req *http.Request) {
636                 var request = new(NatGetTimeouts)
637                 reply, err := rpc.NatGetTimeouts(req.Context(), request)
638                 if err != nil {
639                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
640                         return
641                 }
642                 rep, err := json.MarshalIndent(reply, "", "  ")
643                 if err != nil {
644                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
645                         return
646                 }
647                 w.Write(rep)
648         })
649         mux.HandleFunc("/nat_ha_flush", func(w http.ResponseWriter, req *http.Request) {
650                 var request = new(NatHaFlush)
651                 reply, err := rpc.NatHaFlush(req.Context(), request)
652                 if err != nil {
653                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
654                         return
655                 }
656                 rep, err := json.MarshalIndent(reply, "", "  ")
657                 if err != nil {
658                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
659                         return
660                 }
661                 w.Write(rep)
662         })
663         mux.HandleFunc("/nat_ha_get_failover", func(w http.ResponseWriter, req *http.Request) {
664                 var request = new(NatHaGetFailover)
665                 reply, err := rpc.NatHaGetFailover(req.Context(), request)
666                 if err != nil {
667                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
668                         return
669                 }
670                 rep, err := json.MarshalIndent(reply, "", "  ")
671                 if err != nil {
672                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
673                         return
674                 }
675                 w.Write(rep)
676         })
677         mux.HandleFunc("/nat_ha_get_listener", func(w http.ResponseWriter, req *http.Request) {
678                 var request = new(NatHaGetListener)
679                 reply, err := rpc.NatHaGetListener(req.Context(), request)
680                 if err != nil {
681                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
682                         return
683                 }
684                 rep, err := json.MarshalIndent(reply, "", "  ")
685                 if err != nil {
686                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
687                         return
688                 }
689                 w.Write(rep)
690         })
691         mux.HandleFunc("/nat_ha_resync", func(w http.ResponseWriter, req *http.Request) {
692                 var request = new(NatHaResync)
693                 b, err := ioutil.ReadAll(req.Body)
694                 if err != nil {
695                         http.Error(w, "read body failed", http.StatusBadRequest)
696                         return
697                 }
698                 if err := json.Unmarshal(b, request); err != nil {
699                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
700                         return
701                 }
702                 reply, err := rpc.NatHaResync(req.Context(), request)
703                 if err != nil {
704                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
705                         return
706                 }
707                 rep, err := json.MarshalIndent(reply, "", "  ")
708                 if err != nil {
709                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
710                         return
711                 }
712                 w.Write(rep)
713         })
714         mux.HandleFunc("/nat_ha_set_failover", func(w http.ResponseWriter, req *http.Request) {
715                 var request = new(NatHaSetFailover)
716                 b, err := ioutil.ReadAll(req.Body)
717                 if err != nil {
718                         http.Error(w, "read body failed", http.StatusBadRequest)
719                         return
720                 }
721                 if err := json.Unmarshal(b, request); err != nil {
722                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
723                         return
724                 }
725                 reply, err := rpc.NatHaSetFailover(req.Context(), request)
726                 if err != nil {
727                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
728                         return
729                 }
730                 rep, err := json.MarshalIndent(reply, "", "  ")
731                 if err != nil {
732                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
733                         return
734                 }
735                 w.Write(rep)
736         })
737         mux.HandleFunc("/nat_ha_set_listener", func(w http.ResponseWriter, req *http.Request) {
738                 var request = new(NatHaSetListener)
739                 b, err := ioutil.ReadAll(req.Body)
740                 if err != nil {
741                         http.Error(w, "read body failed", http.StatusBadRequest)
742                         return
743                 }
744                 if err := json.Unmarshal(b, request); err != nil {
745                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
746                         return
747                 }
748                 reply, err := rpc.NatHaSetListener(req.Context(), request)
749                 if err != nil {
750                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
751                         return
752                 }
753                 rep, err := json.MarshalIndent(reply, "", "  ")
754                 if err != nil {
755                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
756                         return
757                 }
758                 w.Write(rep)
759         })
760         mux.HandleFunc("/nat_ipfix_enable_disable", func(w http.ResponseWriter, req *http.Request) {
761                 var request = new(NatIpfixEnableDisable)
762                 b, err := ioutil.ReadAll(req.Body)
763                 if err != nil {
764                         http.Error(w, "read body failed", http.StatusBadRequest)
765                         return
766                 }
767                 if err := json.Unmarshal(b, request); err != nil {
768                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
769                         return
770                 }
771                 reply, err := rpc.NatIpfixEnableDisable(req.Context(), request)
772                 if err != nil {
773                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
774                         return
775                 }
776                 rep, err := json.MarshalIndent(reply, "", "  ")
777                 if err != nil {
778                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
779                         return
780                 }
781                 w.Write(rep)
782         })
783         mux.HandleFunc("/nat_set_addr_and_port_alloc_alg", func(w http.ResponseWriter, req *http.Request) {
784                 var request = new(NatSetAddrAndPortAllocAlg)
785                 b, err := ioutil.ReadAll(req.Body)
786                 if err != nil {
787                         http.Error(w, "read body failed", http.StatusBadRequest)
788                         return
789                 }
790                 if err := json.Unmarshal(b, request); err != nil {
791                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
792                         return
793                 }
794                 reply, err := rpc.NatSetAddrAndPortAllocAlg(req.Context(), request)
795                 if err != nil {
796                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
797                         return
798                 }
799                 rep, err := json.MarshalIndent(reply, "", "  ")
800                 if err != nil {
801                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
802                         return
803                 }
804                 w.Write(rep)
805         })
806         mux.HandleFunc("/nat_set_log_level", func(w http.ResponseWriter, req *http.Request) {
807                 var request = new(NatSetLogLevel)
808                 b, err := ioutil.ReadAll(req.Body)
809                 if err != nil {
810                         http.Error(w, "read body failed", http.StatusBadRequest)
811                         return
812                 }
813                 if err := json.Unmarshal(b, request); err != nil {
814                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
815                         return
816                 }
817                 reply, err := rpc.NatSetLogLevel(req.Context(), request)
818                 if err != nil {
819                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
820                         return
821                 }
822                 rep, err := json.MarshalIndent(reply, "", "  ")
823                 if err != nil {
824                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
825                         return
826                 }
827                 w.Write(rep)
828         })
829         mux.HandleFunc("/nat_set_mss_clamping", func(w http.ResponseWriter, req *http.Request) {
830                 var request = new(NatSetMssClamping)
831                 b, err := ioutil.ReadAll(req.Body)
832                 if err != nil {
833                         http.Error(w, "read body failed", http.StatusBadRequest)
834                         return
835                 }
836                 if err := json.Unmarshal(b, request); err != nil {
837                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
838                         return
839                 }
840                 reply, err := rpc.NatSetMssClamping(req.Context(), request)
841                 if err != nil {
842                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
843                         return
844                 }
845                 rep, err := json.MarshalIndent(reply, "", "  ")
846                 if err != nil {
847                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
848                         return
849                 }
850                 w.Write(rep)
851         })
852         mux.HandleFunc("/nat_set_timeouts", func(w http.ResponseWriter, req *http.Request) {
853                 var request = new(NatSetTimeouts)
854                 b, err := ioutil.ReadAll(req.Body)
855                 if err != nil {
856                         http.Error(w, "read body failed", http.StatusBadRequest)
857                         return
858                 }
859                 if err := json.Unmarshal(b, request); err != nil {
860                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
861                         return
862                 }
863                 reply, err := rpc.NatSetTimeouts(req.Context(), request)
864                 if err != nil {
865                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
866                         return
867                 }
868                 rep, err := json.MarshalIndent(reply, "", "  ")
869                 if err != nil {
870                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
871                         return
872                 }
873                 w.Write(rep)
874         })
875         mux.HandleFunc("/nat_set_workers", func(w http.ResponseWriter, req *http.Request) {
876                 var request = new(NatSetWorkers)
877                 b, err := ioutil.ReadAll(req.Body)
878                 if err != nil {
879                         http.Error(w, "read body failed", http.StatusBadRequest)
880                         return
881                 }
882                 if err := json.Unmarshal(b, request); err != nil {
883                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
884                         return
885                 }
886                 reply, err := rpc.NatSetWorkers(req.Context(), request)
887                 if err != nil {
888                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
889                         return
890                 }
891                 rep, err := json.MarshalIndent(reply, "", "  ")
892                 if err != nil {
893                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
894                         return
895                 }
896                 w.Write(rep)
897         })
898         mux.HandleFunc("/nat_show_config", func(w http.ResponseWriter, req *http.Request) {
899                 var request = new(NatShowConfig)
900                 reply, err := rpc.NatShowConfig(req.Context(), request)
901                 if err != nil {
902                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
903                         return
904                 }
905                 rep, err := json.MarshalIndent(reply, "", "  ")
906                 if err != nil {
907                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
908                         return
909                 }
910                 w.Write(rep)
911         })
912         return http.HandlerFunc(mux.ServeHTTP)
913 }