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("/ipsec_interface_add_del_spd", func(w http.ResponseWriter, req *http.Request) {
14 var request = new(IpsecInterfaceAddDelSpd)
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.IpsecInterfaceAddDelSpd(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("/ipsec_sad_entry_add_del", func(w http.ResponseWriter, req *http.Request) {
37 var request = new(IpsecSadEntryAddDel)
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.IpsecSadEntryAddDel(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("/ipsec_select_backend", func(w http.ResponseWriter, req *http.Request) {
60 var request = new(IpsecSelectBackend)
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.IpsecSelectBackend(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("/ipsec_spd_add_del", func(w http.ResponseWriter, req *http.Request) {
83 var request = new(IpsecSpdAddDel)
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.IpsecSpdAddDel(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("/ipsec_spd_entry_add_del", func(w http.ResponseWriter, req *http.Request) {
106 var request = new(IpsecSpdEntryAddDel)
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.IpsecSpdEntryAddDel(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("/ipsec_tunnel_if_add_del", func(w http.ResponseWriter, req *http.Request) {
129 var request = new(IpsecTunnelIfAddDel)
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.IpsecTunnelIfAddDel(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("/ipsec_tunnel_if_set_sa", func(w http.ResponseWriter, req *http.Request) {
152 var request = new(IpsecTunnelIfSetSa)
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.IpsecTunnelIfSetSa(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("/ipsec_tunnel_protect_del", func(w http.ResponseWriter, req *http.Request) {
175 var request = new(IpsecTunnelProtectDel)
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.IpsecTunnelProtectDel(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("/ipsec_tunnel_protect_update", func(w http.ResponseWriter, req *http.Request) {
198 var request = new(IpsecTunnelProtectUpdate)
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.IpsecTunnelProtectUpdate(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 return http.HandlerFunc(mux.ServeHTTP)