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("/api_versions", func(w http.ResponseWriter, req *http.Request) {
14 var request = new(APIVersions)
15 reply, err := rpc.APIVersions(req.Context(), request)
17 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
20 rep, err := json.MarshalIndent(reply, "", " ")
22 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
27 mux.HandleFunc("/get_first_msg_id", func(w http.ResponseWriter, req *http.Request) {
28 var request = new(GetFirstMsgID)
29 b, err := ioutil.ReadAll(req.Body)
31 http.Error(w, "read body failed", http.StatusBadRequest)
34 if err := json.Unmarshal(b, request); err != nil {
35 http.Error(w, "unmarshal data failed", http.StatusBadRequest)
38 reply, err := rpc.GetFirstMsgID(req.Context(), request)
40 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
43 rep, err := json.MarshalIndent(reply, "", " ")
45 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
50 mux.HandleFunc("/memclnt_create", func(w http.ResponseWriter, req *http.Request) {
51 var request = new(MemclntCreate)
52 b, err := ioutil.ReadAll(req.Body)
54 http.Error(w, "read body failed", http.StatusBadRequest)
57 if err := json.Unmarshal(b, request); err != nil {
58 http.Error(w, "unmarshal data failed", http.StatusBadRequest)
61 reply, err := rpc.MemclntCreate(req.Context(), request)
63 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
66 rep, err := json.MarshalIndent(reply, "", " ")
68 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
73 mux.HandleFunc("/memclnt_delete", func(w http.ResponseWriter, req *http.Request) {
74 var request = new(MemclntDelete)
75 b, err := ioutil.ReadAll(req.Body)
77 http.Error(w, "read body failed", http.StatusBadRequest)
80 if err := json.Unmarshal(b, request); err != nil {
81 http.Error(w, "unmarshal data failed", http.StatusBadRequest)
84 reply, err := rpc.MemclntDelete(req.Context(), request)
86 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
89 rep, err := json.MarshalIndent(reply, "", " ")
91 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
96 mux.HandleFunc("/memclnt_keepalive", func(w http.ResponseWriter, req *http.Request) {
97 var request = new(MemclntKeepalive)
98 reply, err := rpc.MemclntKeepalive(req.Context(), request)
100 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
103 rep, err := json.MarshalIndent(reply, "", " ")
105 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
110 mux.HandleFunc("/rpc_call", func(w http.ResponseWriter, req *http.Request) {
111 var request = new(RPCCall)
112 b, err := ioutil.ReadAll(req.Body)
114 http.Error(w, "read body failed", http.StatusBadRequest)
117 if err := json.Unmarshal(b, request); err != nil {
118 http.Error(w, "unmarshal data failed", http.StatusBadRequest)
121 reply, err := rpc.RPCCall(req.Context(), request)
123 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
126 rep, err := json.MarshalIndent(reply, "", " ")
128 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
133 mux.HandleFunc("/sock_init_shm", func(w http.ResponseWriter, req *http.Request) {
134 var request = new(SockInitShm)
135 b, err := ioutil.ReadAll(req.Body)
137 http.Error(w, "read body failed", http.StatusBadRequest)
140 if err := json.Unmarshal(b, request); err != nil {
141 http.Error(w, "unmarshal data failed", http.StatusBadRequest)
144 reply, err := rpc.SockInitShm(req.Context(), request)
146 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
149 rep, err := json.MarshalIndent(reply, "", " ")
151 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
156 mux.HandleFunc("/sockclnt_create", func(w http.ResponseWriter, req *http.Request) {
157 var request = new(SockclntCreate)
158 b, err := ioutil.ReadAll(req.Body)
160 http.Error(w, "read body failed", http.StatusBadRequest)
163 if err := json.Unmarshal(b, request); err != nil {
164 http.Error(w, "unmarshal data failed", http.StatusBadRequest)
167 reply, err := rpc.SockclntCreate(req.Context(), request)
169 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
172 rep, err := json.MarshalIndent(reply, "", " ")
174 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
179 mux.HandleFunc("/sockclnt_delete", func(w http.ResponseWriter, req *http.Request) {
180 var request = new(SockclntDelete)
181 b, err := ioutil.ReadAll(req.Body)
183 http.Error(w, "read body failed", http.StatusBadRequest)
186 if err := json.Unmarshal(b, request); err != nil {
187 http.Error(w, "unmarshal data failed", http.StatusBadRequest)
190 reply, err := rpc.SockclntDelete(req.Context(), request)
192 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
195 rep, err := json.MarshalIndent(reply, "", " ")
197 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
202 return http.HandlerFunc(mux.ServeHTTP)