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("/trace_profile_add", func(w http.ResponseWriter, req *http.Request) {
14 var request = new(TraceProfileAdd)
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.TraceProfileAdd(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("/trace_profile_del", func(w http.ResponseWriter, req *http.Request) {
37 var request = new(TraceProfileDel)
38 reply, err := rpc.TraceProfileDel(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("/trace_profile_show_config", func(w http.ResponseWriter, req *http.Request) {
51 var request = new(TraceProfileShowConfig)
52 reply, err := rpc.TraceProfileShowConfig(req.Context(), request)
54 http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
57 rep, err := json.MarshalIndent(reply, "", " ")
59 http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
64 return http.HandlerFunc(mux.ServeHTTP)