You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
289 lines
7.1 KiB
289 lines
7.1 KiB
4 years ago
|
// Code generated by protoc-gen-go-http. DO NOT EDIT.
|
||
|
|
||
|
package testproto
|
||
|
|
||
|
import (
|
||
|
context "context"
|
||
|
http1 "github.com/go-kratos/kratos/v2/transport/http"
|
||
4 years ago
|
binding "github.com/go-kratos/kratos/v2/transport/http/binding"
|
||
|
mux "github.com/gorilla/mux"
|
||
4 years ago
|
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.
|
||
4 years ago
|
var _ = new(http.Request)
|
||
|
var _ = new(context.Context)
|
||
|
var _ = binding.MapProto
|
||
|
var _ = mux.NewRouter
|
||
|
|
||
4 years ago
|
const _ = http1.SupportPackageIsVersion1
|
||
|
|
||
4 years ago
|
type EchoServiceHandler interface {
|
||
4 years ago
|
Echo(context.Context, *SimpleMessage) (*SimpleMessage, error)
|
||
|
|
||
|
EchoBody(context.Context, *SimpleMessage) (*SimpleMessage, error)
|
||
|
|
||
|
EchoDelete(context.Context, *SimpleMessage) (*SimpleMessage, error)
|
||
|
|
||
|
EchoPatch(context.Context, *DynamicMessageUpdate) (*DynamicMessageUpdate, error)
|
||
4 years ago
|
|
||
|
EchoResponseBody(context.Context, *DynamicMessageUpdate) (*DynamicMessageUpdate, error)
|
||
4 years ago
|
}
|
||
|
|
||
4 years ago
|
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
|
||
4 years ago
|
if err := h.Decode(r, &in); err != nil {
|
||
4 years ago
|
h.Error(w, r, err)
|
||
|
return
|
||
|
}
|
||
|
|
||
4 years ago
|
if err := binding.MapProto(&in, mux.Vars(r)); err != nil {
|
||
4 years ago
|
h.Error(w, r, err)
|
||
|
return
|
||
|
}
|
||
4 years ago
|
|
||
4 years ago
|
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
|
||
|
}
|
||
4 years ago
|
reply := out.(*SimpleMessage)
|
||
|
if err := h.Encode(w, r, reply); err != nil {
|
||
4 years ago
|
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
|
||
4 years ago
|
if err := h.Decode(r, &in); err != nil {
|
||
4 years ago
|
h.Error(w, r, err)
|
||
|
return
|
||
|
}
|
||
|
|
||
4 years ago
|
if err := binding.MapProto(&in, mux.Vars(r)); err != nil {
|
||
4 years ago
|
h.Error(w, r, err)
|
||
|
return
|
||
|
}
|
||
4 years ago
|
|
||
4 years ago
|
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
|
||
|
}
|
||
4 years ago
|
reply := out.(*SimpleMessage)
|
||
|
if err := h.Encode(w, r, reply); err != nil {
|
||
4 years ago
|
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
|
||
4 years ago
|
if err := h.Decode(r, &in); err != nil {
|
||
4 years ago
|
h.Error(w, r, err)
|
||
|
return
|
||
|
}
|
||
|
|
||
4 years ago
|
if err := binding.MapProto(&in, mux.Vars(r)); err != nil {
|
||
4 years ago
|
h.Error(w, r, err)
|
||
|
return
|
||
|
}
|
||
4 years ago
|
|
||
4 years ago
|
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
|
||
|
}
|
||
4 years ago
|
reply := out.(*SimpleMessage)
|
||
|
if err := h.Encode(w, r, reply); err != nil {
|
||
4 years ago
|
h.Error(w, r, err)
|
||
|
}
|
||
|
}).Methods("GET")
|
||
|
|
||
|
r.HandleFunc("/v1/example/echo2/{no.note}", func(w http.ResponseWriter, r *http.Request) {
|
||
|
var in SimpleMessage
|
||
4 years ago
|
if err := h.Decode(r, &in); err != nil {
|
||
4 years ago
|
h.Error(w, r, err)
|
||
|
return
|
||
|
}
|
||
|
|
||
4 years ago
|
if err := binding.MapProto(&in, mux.Vars(r)); err != nil {
|
||
4 years ago
|
h.Error(w, r, err)
|
||
|
return
|
||
|
}
|
||
4 years ago
|
|
||
4 years ago
|
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
|
||
|
}
|
||
4 years ago
|
reply := out.(*SimpleMessage)
|
||
|
if err := h.Encode(w, r, reply); err != nil {
|
||
4 years ago
|
h.Error(w, r, err)
|
||
|
}
|
||
|
}).Methods("GET")
|
||
|
|
||
|
r.HandleFunc("/v1/example/echo/{id}", func(w http.ResponseWriter, r *http.Request) {
|
||
|
var in SimpleMessage
|
||
4 years ago
|
if err := h.Decode(r, &in); err != nil {
|
||
4 years ago
|
h.Error(w, r, err)
|
||
|
return
|
||
|
}
|
||
|
|
||
4 years ago
|
if err := binding.MapProto(&in, mux.Vars(r)); err != nil {
|
||
4 years ago
|
h.Error(w, r, err)
|
||
|
return
|
||
|
}
|
||
4 years ago
|
|
||
4 years ago
|
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
|
||
|
}
|
||
4 years ago
|
reply := out.(*SimpleMessage)
|
||
|
if err := h.Encode(w, r, reply); err != nil {
|
||
4 years ago
|
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
|
||
|
}
|
||
4 years ago
|
|
||
4 years ago
|
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
|
||
|
}
|
||
4 years ago
|
reply := out.(*SimpleMessage)
|
||
|
if err := h.Encode(w, r, reply); err != nil {
|
||
4 years ago
|
h.Error(w, r, err)
|
||
|
}
|
||
|
}).Methods("POST")
|
||
|
|
||
4 years ago
|
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
|
||
|
}
|
||
4 years ago
|
|
||
4 years ago
|
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
|
||
4 years ago
|
if err := h.Decode(r, &in); err != nil {
|
||
|
h.Error(w, r, err)
|
||
|
return
|
||
|
}
|
||
4 years ago
|
|
||
|
if err := binding.MapProto(&in, mux.Vars(r)); err != nil {
|
||
|
h.Error(w, r, err)
|
||
|
return
|
||
|
}
|
||
|
|
||
4 years ago
|
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
|
||
|
}
|
||
4 years ago
|
reply := out.(*SimpleMessage)
|
||
|
if err := h.Encode(w, r, reply); err != nil {
|
||
4 years ago
|
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
|
||
|
}
|
||
4 years ago
|
|
||
4 years ago
|
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
|
||
|
}
|
||
4 years ago
|
reply := out.(*DynamicMessageUpdate)
|
||
|
if err := h.Encode(w, r, reply); err != nil {
|
||
4 years ago
|
h.Error(w, r, err)
|
||
|
}
|
||
|
}).Methods("PATCH")
|
||
|
|
||
|
return r
|
||
4 years ago
|
}
|