Improve binapi generator
[govpp.git] / binapi / builtinurl / builtinurl_rest.ba.go
1 // Code generated by GoVPP's binapi-generator. DO NOT EDIT.
2
3 package builtinurl
4
5 import (
6         "encoding/json"
7         "net/http"
8 )
9
10 func RESTHandler(rpc RPCService) http.Handler {
11         mux := http.NewServeMux()
12         mux.HandleFunc("/builtinurl_enable", func(w http.ResponseWriter, req *http.Request) {
13                 var request = new(BuiltinurlEnable)
14                 reply, err := rpc.BuiltinurlEnable(req.Context(), request)
15                 if err != nil {
16                         http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError)
17                         return
18                 }
19                 rep, err := json.MarshalIndent(reply, "", "  ")
20                 if err != nil {
21                         http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError)
22                         return
23                 }
24                 w.Write(rep)
25         })
26         return http.HandlerFunc(mux.ServeHTTP)
27 }