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("/app_add_cert_key_pair", func(w http.ResponseWriter, req *http.Request) {
14 var request = new(AppAddCertKeyPair)
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.AppAddCertKeyPair(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("/app_attach", func(w http.ResponseWriter, req *http.Request) {
37 var request = new(AppAttach)
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.AppAttach(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("/app_del_cert_key_pair", func(w http.ResponseWriter, req *http.Request) {
60 var request = new(AppDelCertKeyPair)
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.AppDelCertKeyPair(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("/app_namespace_add_del", func(w http.ResponseWriter, req *http.Request) {
83 var request = new(AppNamespaceAddDel)
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.AppNamespaceAddDel(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("/app_worker_add_del", func(w http.ResponseWriter, req *http.Request) {
106 var request = new(AppWorkerAddDel)
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.AppWorkerAddDel(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("/application_detach", func(w http.ResponseWriter, req *http.Request) {
129 var request = new(ApplicationDetach)
130 reply, err := rpc.ApplicationDetach(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("/application_tls_cert_add", func(w http.ResponseWriter, req *http.Request) {
143 var request = new(ApplicationTLSCertAdd)
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.ApplicationTLSCertAdd(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("/application_tls_key_add", func(w http.ResponseWriter, req *http.Request) {
166 var request = new(ApplicationTLSKeyAdd)
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.ApplicationTLSKeyAdd(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("/session_enable_disable", func(w http.ResponseWriter, req *http.Request) {
189 var request = new(SessionEnableDisable)
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.SessionEnableDisable(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("/session_rule_add_del", func(w http.ResponseWriter, req *http.Request) {
212 var request = new(SessionRuleAddDel)
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.SessionRuleAddDel(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 return http.HandlerFunc(mux.ServeHTTP)