Updated changelog for v0.4.0
[govpp.git] / binapi / memclnt / memclnt_rest.ba.go
1 // Code generated by GoVPP's binapi-generator. DO NOT EDIT.
2
3 package memclnt
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("/api_versions", func(w http.ResponseWriter, req *http.Request) {
14                 var request = new(APIVersions)
15                 reply, err := rpc.APIVersions(req.Context(), request)
16                 if err != nil {
17                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
18                         return
19                 }
20                 rep, err := json.MarshalIndent(reply, "", "  ")
21                 if err != nil {
22                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
23                         return
24                 }
25                 w.Write(rep)
26         })
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)
30                 if err != nil {
31                         http.Error(w, "read body failed", http.StatusBadRequest)
32                         return
33                 }
34                 if err := json.Unmarshal(b, request); err != nil {
35                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
36                         return
37                 }
38                 reply, err := rpc.GetFirstMsgID(req.Context(), request)
39                 if err != nil {
40                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
41                         return
42                 }
43                 rep, err := json.MarshalIndent(reply, "", "  ")
44                 if err != nil {
45                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
46                         return
47                 }
48                 w.Write(rep)
49         })
50         mux.HandleFunc("/memclnt_create", func(w http.ResponseWriter, req *http.Request) {
51                 var request = new(MemclntCreate)
52                 b, err := ioutil.ReadAll(req.Body)
53                 if err != nil {
54                         http.Error(w, "read body failed", http.StatusBadRequest)
55                         return
56                 }
57                 if err := json.Unmarshal(b, request); err != nil {
58                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
59                         return
60                 }
61                 reply, err := rpc.MemclntCreate(req.Context(), request)
62                 if err != nil {
63                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
64                         return
65                 }
66                 rep, err := json.MarshalIndent(reply, "", "  ")
67                 if err != nil {
68                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
69                         return
70                 }
71                 w.Write(rep)
72         })
73         mux.HandleFunc("/memclnt_delete", func(w http.ResponseWriter, req *http.Request) {
74                 var request = new(MemclntDelete)
75                 b, err := ioutil.ReadAll(req.Body)
76                 if err != nil {
77                         http.Error(w, "read body failed", http.StatusBadRequest)
78                         return
79                 }
80                 if err := json.Unmarshal(b, request); err != nil {
81                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
82                         return
83                 }
84                 reply, err := rpc.MemclntDelete(req.Context(), request)
85                 if err != nil {
86                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
87                         return
88                 }
89                 rep, err := json.MarshalIndent(reply, "", "  ")
90                 if err != nil {
91                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
92                         return
93                 }
94                 w.Write(rep)
95         })
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)
99                 if err != nil {
100                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
101                         return
102                 }
103                 rep, err := json.MarshalIndent(reply, "", "  ")
104                 if err != nil {
105                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
106                         return
107                 }
108                 w.Write(rep)
109         })
110         mux.HandleFunc("/rpc_call", func(w http.ResponseWriter, req *http.Request) {
111                 var request = new(RPCCall)
112                 b, err := ioutil.ReadAll(req.Body)
113                 if err != nil {
114                         http.Error(w, "read body failed", http.StatusBadRequest)
115                         return
116                 }
117                 if err := json.Unmarshal(b, request); err != nil {
118                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
119                         return
120                 }
121                 reply, err := rpc.RPCCall(req.Context(), request)
122                 if err != nil {
123                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
124                         return
125                 }
126                 rep, err := json.MarshalIndent(reply, "", "  ")
127                 if err != nil {
128                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
129                         return
130                 }
131                 w.Write(rep)
132         })
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)
136                 if err != nil {
137                         http.Error(w, "read body failed", http.StatusBadRequest)
138                         return
139                 }
140                 if err := json.Unmarshal(b, request); err != nil {
141                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
142                         return
143                 }
144                 reply, err := rpc.SockInitShm(req.Context(), request)
145                 if err != nil {
146                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
147                         return
148                 }
149                 rep, err := json.MarshalIndent(reply, "", "  ")
150                 if err != nil {
151                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
152                         return
153                 }
154                 w.Write(rep)
155         })
156         mux.HandleFunc("/sockclnt_create", func(w http.ResponseWriter, req *http.Request) {
157                 var request = new(SockclntCreate)
158                 b, err := ioutil.ReadAll(req.Body)
159                 if err != nil {
160                         http.Error(w, "read body failed", http.StatusBadRequest)
161                         return
162                 }
163                 if err := json.Unmarshal(b, request); err != nil {
164                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
165                         return
166                 }
167                 reply, err := rpc.SockclntCreate(req.Context(), request)
168                 if err != nil {
169                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
170                         return
171                 }
172                 rep, err := json.MarshalIndent(reply, "", "  ")
173                 if err != nil {
174                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
175                         return
176                 }
177                 w.Write(rep)
178         })
179         mux.HandleFunc("/sockclnt_delete", func(w http.ResponseWriter, req *http.Request) {
180                 var request = new(SockclntDelete)
181                 b, err := ioutil.ReadAll(req.Body)
182                 if err != nil {
183                         http.Error(w, "read body failed", http.StatusBadRequest)
184                         return
185                 }
186                 if err := json.Unmarshal(b, request); err != nil {
187                         http.Error(w, "unmarshal data failed", http.StatusBadRequest)
188                         return
189                 }
190                 reply, err := rpc.SockclntDelete(req.Context(), request)
191                 if err != nil {
192                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
193                         return
194                 }
195                 rep, err := json.MarshalIndent(reply, "", "  ")
196                 if err != nil {
197                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
198                         return
199                 }
200                 w.Write(rep)
201         })
202         return http.HandlerFunc(mux.ServeHTTP)
203 }