1 // Code generated by GoVPP's binapi-generator. DO NOT EDIT.
11 func HTTPHandler(rpc RPCService) http.Handler {
12 mux := http.NewServeMux()
13 mux.HandleFunc("/add_node_next", func(w http.ResponseWriter, req *http.Request) {
14 var request = new(AddNodeNext)
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.AddNodeNext(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("/cli", func(w http.ResponseWriter, req *http.Request) {
37 var request = new(Cli)
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.Cli(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("/cli_inband", func(w http.ResponseWriter, req *http.Request) {
60 var request = new(CliInband)
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.CliInband(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("/control_ping", func(w http.ResponseWriter, req *http.Request) {
83 var request = new(ControlPing)
84 reply, err := rpc.ControlPing(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("/get_f64_endian_value", func(w http.ResponseWriter, req *http.Request) {
97 var request = new(GetF64EndianValue)
98 b, err := ioutil.ReadAll(req.Body)
100 http.Error(w, "read body failed", http.StatusBadRequest)
103 if err := json.Unmarshal(b, request); err != nil {
104 http.Error(w, "unmarshal data failed", http.StatusBadRequest)
107 reply, err := rpc.GetF64EndianValue(req.Context(), request)
109 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
112 rep, err := json.MarshalIndent(reply, "", " ")
114 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
119 mux.HandleFunc("/get_f64_increment_by_one", func(w http.ResponseWriter, req *http.Request) {
120 var request = new(GetF64IncrementByOne)
121 b, err := ioutil.ReadAll(req.Body)
123 http.Error(w, "read body failed", http.StatusBadRequest)
126 if err := json.Unmarshal(b, request); err != nil {
127 http.Error(w, "unmarshal data failed", http.StatusBadRequest)
130 reply, err := rpc.GetF64IncrementByOne(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("/get_next_index", func(w http.ResponseWriter, req *http.Request) {
143 var request = new(GetNextIndex)
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.GetNextIndex(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("/get_node_graph", func(w http.ResponseWriter, req *http.Request) {
166 var request = new(GetNodeGraph)
167 reply, err := rpc.GetNodeGraph(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("/get_node_index", func(w http.ResponseWriter, req *http.Request) {
180 var request = new(GetNodeIndex)
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.GetNodeIndex(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 mux.HandleFunc("/show_threads", func(w http.ResponseWriter, req *http.Request) {
203 var request = new(ShowThreads)
204 reply, err := rpc.ShowThreads(req.Context(), request)
206 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
209 rep, err := json.MarshalIndent(reply, "", " ")
211 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
216 mux.HandleFunc("/show_version", func(w http.ResponseWriter, req *http.Request) {
217 var request = new(ShowVersion)
218 reply, err := rpc.ShowVersion(req.Context(), request)
220 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
223 rep, err := json.MarshalIndent(reply, "", " ")
225 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
230 mux.HandleFunc("/show_vpe_system_time", func(w http.ResponseWriter, req *http.Request) {
231 var request = new(ShowVpeSystemTime)
232 reply, err := rpc.ShowVpeSystemTime(req.Context(), request)
234 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
237 rep, err := json.MarshalIndent(reply, "", " ")
239 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
244 return http.HandlerFunc(mux.ServeHTTP)