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("/map_add_del_rule", func(w http.ResponseWriter, req *http.Request) {
14 var request = new(MapAddDelRule)
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.MapAddDelRule(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("/map_add_domain", func(w http.ResponseWriter, req *http.Request) {
37 var request = new(MapAddDomain)
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.MapAddDomain(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("/map_del_domain", func(w http.ResponseWriter, req *http.Request) {
60 var request = new(MapDelDomain)
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.MapDelDomain(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("/map_if_enable_disable", func(w http.ResponseWriter, req *http.Request) {
83 var request = new(MapIfEnableDisable)
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.MapIfEnableDisable(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("/map_param_add_del_pre_resolve", func(w http.ResponseWriter, req *http.Request) {
106 var request = new(MapParamAddDelPreResolve)
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.MapParamAddDelPreResolve(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("/map_param_get", func(w http.ResponseWriter, req *http.Request) {
129 var request = new(MapParamGet)
130 reply, err := rpc.MapParamGet(req.Context(), request)
132 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
135 rep, err := json.MarshalIndent(reply, "", " ")
137 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
142 mux.HandleFunc("/map_param_set_fragmentation", func(w http.ResponseWriter, req *http.Request) {
143 var request = new(MapParamSetFragmentation)
144 b, err := ioutil.ReadAll(req.Body)
146 http.Error(w, "read body failed", http.StatusBadRequest)
149 if err := json.Unmarshal(b, request); err != nil {
150 http.Error(w, "unmarshal data failed", http.StatusBadRequest)
153 reply, err := rpc.MapParamSetFragmentation(req.Context(), request)
155 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
158 rep, err := json.MarshalIndent(reply, "", " ")
160 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
165 mux.HandleFunc("/map_param_set_icmp", func(w http.ResponseWriter, req *http.Request) {
166 var request = new(MapParamSetICMP)
167 b, err := ioutil.ReadAll(req.Body)
169 http.Error(w, "read body failed", http.StatusBadRequest)
172 if err := json.Unmarshal(b, request); err != nil {
173 http.Error(w, "unmarshal data failed", http.StatusBadRequest)
176 reply, err := rpc.MapParamSetICMP(req.Context(), request)
178 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
181 rep, err := json.MarshalIndent(reply, "", " ")
183 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
188 mux.HandleFunc("/map_param_set_icmp6", func(w http.ResponseWriter, req *http.Request) {
189 var request = new(MapParamSetICMP6)
190 b, err := ioutil.ReadAll(req.Body)
192 http.Error(w, "read body failed", http.StatusBadRequest)
195 if err := json.Unmarshal(b, request); err != nil {
196 http.Error(w, "unmarshal data failed", http.StatusBadRequest)
199 reply, err := rpc.MapParamSetICMP6(req.Context(), request)
201 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
204 rep, err := json.MarshalIndent(reply, "", " ")
206 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
211 mux.HandleFunc("/map_param_set_security_check", func(w http.ResponseWriter, req *http.Request) {
212 var request = new(MapParamSetSecurityCheck)
213 b, err := ioutil.ReadAll(req.Body)
215 http.Error(w, "read body failed", http.StatusBadRequest)
218 if err := json.Unmarshal(b, request); err != nil {
219 http.Error(w, "unmarshal data failed", http.StatusBadRequest)
222 reply, err := rpc.MapParamSetSecurityCheck(req.Context(), request)
224 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
227 rep, err := json.MarshalIndent(reply, "", " ")
229 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
234 mux.HandleFunc("/map_param_set_tcp", func(w http.ResponseWriter, req *http.Request) {
235 var request = new(MapParamSetTCP)
236 b, err := ioutil.ReadAll(req.Body)
238 http.Error(w, "read body failed", http.StatusBadRequest)
241 if err := json.Unmarshal(b, request); err != nil {
242 http.Error(w, "unmarshal data failed", http.StatusBadRequest)
245 reply, err := rpc.MapParamSetTCP(req.Context(), request)
247 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
250 rep, err := json.MarshalIndent(reply, "", " ")
252 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
257 mux.HandleFunc("/map_param_set_traffic_class", func(w http.ResponseWriter, req *http.Request) {
258 var request = new(MapParamSetTrafficClass)
259 b, err := ioutil.ReadAll(req.Body)
261 http.Error(w, "read body failed", http.StatusBadRequest)
264 if err := json.Unmarshal(b, request); err != nil {
265 http.Error(w, "unmarshal data failed", http.StatusBadRequest)
268 reply, err := rpc.MapParamSetTrafficClass(req.Context(), request)
270 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
273 rep, err := json.MarshalIndent(reply, "", " ")
275 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
280 mux.HandleFunc("/map_summary_stats", func(w http.ResponseWriter, req *http.Request) {
281 var request = new(MapSummaryStats)
282 reply, err := rpc.MapSummaryStats(req.Context(), request)
284 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
287 rep, err := json.MarshalIndent(reply, "", " ")
289 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
294 return http.HandlerFunc(mux.ServeHTTP)