// Code generated by protoc-gen-go-http. DO NOT EDIT. package testproto import ( context "context" http1 "github.com/go-kratos/kratos/v2/transport/http" binding "github.com/go-kratos/kratos/v2/transport/http/binding" mux "github.com/gorilla/mux" http "net/http" ) // This is a compile-time assertion to ensure that this generated file // is compatible with the kratos package it is being compiled against. var _ = new(http.Request) var _ = new(context.Context) var _ = binding.MapProto var _ = mux.NewRouter const _ = http1.SupportPackageIsVersion1 type EchoServiceHandler interface { Echo(context.Context, *SimpleMessage) (*SimpleMessage, error) EchoBody(context.Context, *SimpleMessage) (*SimpleMessage, error) EchoDelete(context.Context, *SimpleMessage) (*SimpleMessage, error) EchoPatch(context.Context, *DynamicMessageUpdate) (*DynamicMessageUpdate, error) EchoResponseBody(context.Context, *DynamicMessageUpdate) (*DynamicMessageUpdate, error) } func NewEchoServiceHandler(srv EchoServiceHandler, opts ...http1.HandleOption) http.Handler { h := http1.DefaultHandleOptions() for _, o := range opts { o(&h) } r := mux.NewRouter() r.HandleFunc("/v1/example/echo/{id}/{num}", func(w http.ResponseWriter, r *http.Request) { var in SimpleMessage if err := h.Decode(r, &in); err != nil { h.Error(w, r, err) return } if err := binding.BindVars(mux.Vars(r), &in); err != nil { h.Error(w, r, err) return } next := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.Echo(ctx, req.(*SimpleMessage)) } if h.Middleware != nil { next = h.Middleware(next) } out, err := next(r.Context(), &in) if err != nil { h.Error(w, r, err) return } reply := out.(*SimpleMessage) if err := h.Encode(w, r, reply); err != nil { h.Error(w, r, err) } }).Methods("GET") r.HandleFunc("/v1/example/echo/{id}/{num}/{lang}", func(w http.ResponseWriter, r *http.Request) { var in SimpleMessage if err := h.Decode(r, &in); err != nil { h.Error(w, r, err) return } if err := binding.BindVars(mux.Vars(r), &in); err != nil { h.Error(w, r, err) return } next := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.Echo(ctx, req.(*SimpleMessage)) } if h.Middleware != nil { next = h.Middleware(next) } out, err := next(r.Context(), &in) if err != nil { h.Error(w, r, err) return } reply := out.(*SimpleMessage) if err := h.Encode(w, r, reply); err != nil { h.Error(w, r, err) } }).Methods("GET") r.HandleFunc("/v1/example/echo1/{id}/{line_num}/{status.note}", func(w http.ResponseWriter, r *http.Request) { var in SimpleMessage if err := h.Decode(r, &in); err != nil { h.Error(w, r, err) return } if err := binding.BindVars(mux.Vars(r), &in); err != nil { h.Error(w, r, err) return } next := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.Echo(ctx, req.(*SimpleMessage)) } if h.Middleware != nil { next = h.Middleware(next) } out, err := next(r.Context(), &in) if err != nil { h.Error(w, r, err) return } reply := out.(*SimpleMessage) if err := h.Encode(w, r, reply); err != nil { h.Error(w, r, err) } }).Methods("GET") r.HandleFunc("/v1/example/echo2/{no.note}", func(w http.ResponseWriter, r *http.Request) { var in SimpleMessage if err := h.Decode(r, &in); err != nil { h.Error(w, r, err) return } if err := binding.BindVars(mux.Vars(r), &in); err != nil { h.Error(w, r, err) return } next := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.Echo(ctx, req.(*SimpleMessage)) } if h.Middleware != nil { next = h.Middleware(next) } out, err := next(r.Context(), &in) if err != nil { h.Error(w, r, err) return } reply := out.(*SimpleMessage) if err := h.Encode(w, r, reply); err != nil { h.Error(w, r, err) } }).Methods("GET") r.HandleFunc("/v1/example/echo/{id}", func(w http.ResponseWriter, r *http.Request) { var in SimpleMessage if err := h.Decode(r, &in); err != nil { h.Error(w, r, err) return } if err := binding.BindVars(mux.Vars(r), &in); err != nil { h.Error(w, r, err) return } next := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.Echo(ctx, req.(*SimpleMessage)) } if h.Middleware != nil { next = h.Middleware(next) } out, err := next(r.Context(), &in) if err != nil { h.Error(w, r, err) return } reply := out.(*SimpleMessage) if err := h.Encode(w, r, reply); err != nil { h.Error(w, r, err) } }).Methods("POST") r.HandleFunc("/v1/example/echo_body", func(w http.ResponseWriter, r *http.Request) { var in SimpleMessage if err := h.Decode(r, &in); err != nil { h.Error(w, r, err) return } next := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.EchoBody(ctx, req.(*SimpleMessage)) } if h.Middleware != nil { next = h.Middleware(next) } out, err := next(r.Context(), &in) if err != nil { h.Error(w, r, err) return } reply := out.(*SimpleMessage) if err := h.Encode(w, r, reply); err != nil { h.Error(w, r, err) } }).Methods("POST") r.HandleFunc("/v1/example/echo_response_body", func(w http.ResponseWriter, r *http.Request) { var in DynamicMessageUpdate if err := h.Decode(r, &in); err != nil { h.Error(w, r, err) return } next := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.EchoResponseBody(ctx, req.(*DynamicMessageUpdate)) } if h.Middleware != nil { next = h.Middleware(next) } out, err := next(r.Context(), &in) if err != nil { h.Error(w, r, err) return } reply := out.(*DynamicMessageUpdate) if err := h.Encode(w, r, reply.Body); err != nil { h.Error(w, r, err) } }).Methods("POST") r.HandleFunc("/v1/example/echo_delete/{id}/{num}", func(w http.ResponseWriter, r *http.Request) { var in SimpleMessage if err := h.Decode(r, &in); err != nil { h.Error(w, r, err) return } if err := binding.BindVars(mux.Vars(r), &in); err != nil { h.Error(w, r, err) return } next := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.EchoDelete(ctx, req.(*SimpleMessage)) } if h.Middleware != nil { next = h.Middleware(next) } out, err := next(r.Context(), &in) if err != nil { h.Error(w, r, err) return } reply := out.(*SimpleMessage) if err := h.Encode(w, r, reply); err != nil { h.Error(w, r, err) } }).Methods("DELETE") r.HandleFunc("/v1/example/echo_patch", func(w http.ResponseWriter, r *http.Request) { var in DynamicMessageUpdate if err := h.Decode(r, &in.Body); err != nil { h.Error(w, r, err) return } next := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.EchoPatch(ctx, req.(*DynamicMessageUpdate)) } if h.Middleware != nil { next = h.Middleware(next) } out, err := next(r.Context(), &in) if err != nil { h.Error(w, r, err) return } reply := out.(*DynamicMessageUpdate) if err := h.Encode(w, r, reply); err != nil { h.Error(w, r, err) } }).Methods("PATCH") return r } type EchoServiceHTTPClient interface { Echo(ctx context.Context, req *SimpleMessage, opts ...http1.CallOption) (rsp *SimpleMessage, err error) EchoBody(ctx context.Context, req *SimpleMessage, opts ...http1.CallOption) (rsp *SimpleMessage, err error) EchoDelete(ctx context.Context, req *SimpleMessage, opts ...http1.CallOption) (rsp *SimpleMessage, err error) EchoPatch(ctx context.Context, req *DynamicMessageUpdate, opts ...http1.CallOption) (rsp *DynamicMessageUpdate, err error) EchoResponseBody(ctx context.Context, req *DynamicMessageUpdate, opts ...http1.CallOption) (rsp *DynamicMessageUpdate, err error) } type EchoServiceHTTPClientImpl struct { cc *http1.Client } func NewEchoServiceHTTPClient(client *http1.Client) EchoServiceHTTPClient { return &EchoServiceHTTPClientImpl{client} } func (c *EchoServiceHTTPClientImpl) Echo(ctx context.Context, in *SimpleMessage, opts ...http1.CallOption) (out *SimpleMessage, err error) { path := binding.EncodePath("POST", "/v1/example/echo/{id}", in) out = &SimpleMessage{} err = c.cc.Invoke(ctx, path, nil, &out, http1.Method("POST"), http1.PathPattern("/v1/example/echo/{id}")) if err != nil { return } return } func (c *EchoServiceHTTPClientImpl) EchoBody(ctx context.Context, in *SimpleMessage, opts ...http1.CallOption) (out *SimpleMessage, err error) { path := binding.EncodePath("POST", "/v1/example/echo_body", in) out = &SimpleMessage{} err = c.cc.Invoke(ctx, path, in, &out, http1.Method("POST"), http1.PathPattern("/v1/example/echo_body")) if err != nil { return } return } func (c *EchoServiceHTTPClientImpl) EchoDelete(ctx context.Context, in *SimpleMessage, opts ...http1.CallOption) (out *SimpleMessage, err error) { path := binding.EncodePath("DELETE", "/v1/example/echo_delete/{id}/{num}", in) out = &SimpleMessage{} err = c.cc.Invoke(ctx, path, nil, &out, http1.Method("DELETE"), http1.PathPattern("/v1/example/echo_delete/{id}/{num}")) if err != nil { return } return } func (c *EchoServiceHTTPClientImpl) EchoPatch(ctx context.Context, in *DynamicMessageUpdate, opts ...http1.CallOption) (out *DynamicMessageUpdate, err error) { path := binding.EncodePath("PATCH", "/v1/example/echo_patch", in) out = &DynamicMessageUpdate{} err = c.cc.Invoke(ctx, path, in.Body, &out, http1.Method("PATCH"), http1.PathPattern("/v1/example/echo_patch")) if err != nil { return } return } func (c *EchoServiceHTTPClientImpl) EchoResponseBody(ctx context.Context, in *DynamicMessageUpdate, opts ...http1.CallOption) (out *DynamicMessageUpdate, err error) { path := binding.EncodePath("POST", "/v1/example/echo_response_body", in) out = &DynamicMessageUpdate{} err = c.cc.Invoke(ctx, path, in, &out.Body, http1.Method("POST"), http1.PathPattern("/v1/example/echo_response_body")) if err != nil { return } return }