diff options
Diffstat (limited to 'binapi/dslite/dslite_rest.ba.go')
-rw-r--r-- | binapi/dslite/dslite_rest.ba.go | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/binapi/dslite/dslite_rest.ba.go b/binapi/dslite/dslite_rest.ba.go new file mode 100644 index 0000000..eba86b0 --- /dev/null +++ b/binapi/dslite/dslite_rest.ba.go @@ -0,0 +1,111 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package dslite + +import ( + "encoding/json" + "io/ioutil" + "net/http" +) + +func RESTHandler(rpc RPCService) http.Handler { + mux := http.NewServeMux() + mux.HandleFunc("/dslite_add_del_pool_addr_range", func(w http.ResponseWriter, req *http.Request) { + var request = new(DsliteAddDelPoolAddrRange) + b, err := ioutil.ReadAll(req.Body) + if err != nil { + http.Error(w, "read body failed", http.StatusBadRequest) + return + } + if err := json.Unmarshal(b, request); err != nil { + http.Error(w, "unmarshal data failed", http.StatusBadRequest) + return + } + reply, err := rpc.DsliteAddDelPoolAddrRange(req.Context(), request) + if err != nil { + http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError) + return + } + rep, err := json.MarshalIndent(reply, "", " ") + if err != nil { + http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError) + return + } + w.Write(rep) + }) + mux.HandleFunc("/dslite_get_aftr_addr", func(w http.ResponseWriter, req *http.Request) { + var request = new(DsliteGetAftrAddr) + reply, err := rpc.DsliteGetAftrAddr(req.Context(), request) + if err != nil { + http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError) + return + } + rep, err := json.MarshalIndent(reply, "", " ") + if err != nil { + http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError) + return + } + w.Write(rep) + }) + mux.HandleFunc("/dslite_get_b4_addr", func(w http.ResponseWriter, req *http.Request) { + var request = new(DsliteGetB4Addr) + reply, err := rpc.DsliteGetB4Addr(req.Context(), request) + if err != nil { + http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError) + return + } + rep, err := json.MarshalIndent(reply, "", " ") + if err != nil { + http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError) + return + } + w.Write(rep) + }) + mux.HandleFunc("/dslite_set_aftr_addr", func(w http.ResponseWriter, req *http.Request) { + var request = new(DsliteSetAftrAddr) + b, err := ioutil.ReadAll(req.Body) + if err != nil { + http.Error(w, "read body failed", http.StatusBadRequest) + return + } + if err := json.Unmarshal(b, request); err != nil { + http.Error(w, "unmarshal data failed", http.StatusBadRequest) + return + } + reply, err := rpc.DsliteSetAftrAddr(req.Context(), request) + if err != nil { + http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError) + return + } + rep, err := json.MarshalIndent(reply, "", " ") + if err != nil { + http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError) + return + } + w.Write(rep) + }) + mux.HandleFunc("/dslite_set_b4_addr", func(w http.ResponseWriter, req *http.Request) { + var request = new(DsliteSetB4Addr) + b, err := ioutil.ReadAll(req.Body) + if err != nil { + http.Error(w, "read body failed", http.StatusBadRequest) + return + } + if err := json.Unmarshal(b, request); err != nil { + http.Error(w, "unmarshal data failed", http.StatusBadRequest) + return + } + reply, err := rpc.DsliteSetB4Addr(req.Context(), request) + if err != nil { + http.Error(w, "request failed: "+err.Error(), http.StatusInternalServerError) + return + } + rep, err := json.MarshalIndent(reply, "", " ") + if err != nil { + http.Error(w, "marshal failed: "+err.Error(), http.StatusInternalServerError) + return + } + w.Write(rep) + }) + return http.HandlerFunc(mux.ServeHTTP) +} |