本文整理匯總了Golang中github.com/gengo/grpc-gateway/runtime.ServeMux.Handle方法的典型用法代碼示例。如果您正苦於以下問題:Golang ServeMux.Handle方法的具體用法?Golang ServeMux.Handle怎麽用?Golang ServeMux.Handle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/gengo/grpc-gateway/runtime.ServeMux
的用法示例。
在下文中一共展示了ServeMux.Handle方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: RegisterEchoServiceHandler
// RegisterEchoServiceHandler registers the http handlers for service EchoService to "mux".
// The handlers forward requests to the grpc endpoint over "conn".
func RegisterEchoServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
client := NewEchoServiceClient(conn)
mux.Handle("POST", pattern_EchoService_Echo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
resp, err := request_EchoService_Echo_0(runtime.AnnotateContext(ctx, req), client, req, pathParams)
if err != nil {
runtime.HTTPError(ctx, w, req, err)
return
}
forward_EchoService_Echo_0(ctx, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("POST", pattern_EchoService_EchoBody_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
resp, err := request_EchoService_EchoBody_0(runtime.AnnotateContext(ctx, req), client, req, pathParams)
if err != nil {
runtime.HTTPError(ctx, w, req, err)
return
}
forward_EchoService_EchoBody_0(ctx, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
示例2: RegisterAPIHandler
// RegisterAPIHandler registers the http handlers for service API to "mux".
// The handlers forward requests to the grpc endpoint over "conn".
func RegisterAPIHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
client := NewAPIClient(conn)
mux.Handle("GET", pattern_API_GetVersion_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(ctx)
defer cancel()
if cn, ok := w.(http.CloseNotifier); ok {
go func(done <-chan struct{}, closed <-chan bool) {
select {
case <-done:
case <-closed:
cancel()
}
}(ctx.Done(), cn.CloseNotify())
}
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, req)
if err != nil {
runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
}
resp, md, err := request_API_GetVersion_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
return
}
forward_API_GetVersion_0(ctx, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
示例3: RegisterEchoServiceHandler
// RegisterEchoServiceHandler registers the http handlers for service EchoService to "mux".
// The handlers forward requests to the grpc endpoint over "conn".
func RegisterEchoServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
client := NewEchoServiceClient(conn)
mux.Handle("POST", pattern_EchoService_Echo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(ctx)
defer cancel()
if cn, ok := w.(http.CloseNotifier); ok {
go func(done <-chan struct{}, closed <-chan bool) {
select {
case <-done:
case <-closed:
cancel()
}
}(ctx.Done(), cn.CloseNotify())
}
resp, md, err := request_EchoService_Echo_0(runtime.AnnotateContext(ctx, req), client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, w, req, err)
return
}
forward_EchoService_Echo_0(ctx, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("POST", pattern_EchoService_EchoBody_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(ctx)
defer cancel()
if cn, ok := w.(http.CloseNotifier); ok {
go func(done <-chan struct{}, closed <-chan bool) {
select {
case <-done:
case <-closed:
cancel()
}
}(ctx.Done(), cn.CloseNotify())
}
resp, md, err := request_EchoService_EchoBody_0(runtime.AnnotateContext(ctx, req), client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, w, req, err)
return
}
forward_EchoService_EchoBody_0(ctx, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
示例4: RegisterAPIHandler
// RegisterAPIHandler registers the http handlers for service API to "mux".
// The handlers forward requests to the grpc endpoint over "conn".
func RegisterAPIHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
client := NewAPIClient(conn)
mux.Handle("GET", pattern_API_GetVersion_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
resp, err := request_API_GetVersion_0(runtime.AnnotateContext(ctx, req), client, req, pathParams)
if err != nil {
runtime.HTTPError(ctx, w, err)
return
}
forward_API_GetVersion_0(ctx, w, req, resp)
})
return nil
}
示例5: RegisterEchoServiceHandler
// RegisterEchoServiceHandler registers the http handlers for service EchoService to "mux".
// The handlers forward requests to the grpc endpoint over "conn".
func RegisterEchoServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
client := NewEchoServiceClient(conn)
mux.Handle("POST", pattern_EchoService_Echo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(ctx)
closeNotifier, ok := w.(http.CloseNotifier)
if ok {
go func() {
<-closeNotifier.CloseNotify()
cancel()
}()
}
resp, err := request_EchoService_Echo_0(runtime.AnnotateContext(ctx, req), client, req, pathParams)
if err != nil {
runtime.HTTPError(ctx, w, req, err)
return
}
forward_EchoService_Echo_0(ctx, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("POST", pattern_EchoService_EchoBody_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(ctx)
closeNotifier, ok := w.(http.CloseNotifier)
if ok {
go func() {
<-closeNotifier.CloseNotify()
cancel()
}()
}
resp, err := request_EchoService_EchoBody_0(runtime.AnnotateContext(ctx, req), client, req, pathParams)
if err != nil {
runtime.HTTPError(ctx, w, req, err)
return
}
forward_EchoService_EchoBody_0(ctx, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
示例6: RegisterSlackHandler
// RegisterSlackHandler registers the http handlers for service Slack to "mux".
// The handlers forward requests to the grpc endpoint over "conn".
func RegisterSlackHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
client := NewSlackClient(conn)
mux.Handle("GET", pattern_Slack_Stats_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
w.Header().Set("Access-Control-Allow-Origin", "*")
w.Header().Set("Access-Control-Allow-Methods", "GET, OPTIONS")
w.Header().Set("Access-Control-Allow-Headers",
"Accept, Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization",
)
resp, err := request_Slack_Stats_0(runtime.AnnotateContext(ctx, req), client, req, pathParams)
if err != nil {
runtime.HTTPError(ctx, w, err)
return
}
forward_Slack_Stats_0(ctx, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_Slack_Invite_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
w.Header().Set("Access-Control-Allow-Origin", "*")
w.Header().Set("Access-Control-Allow-Methods", "GET, OPTIONS")
w.Header().Set("Access-Control-Allow-Headers",
"Accept, Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization",
)
resp, err := request_Slack_Invite_0(runtime.AnnotateContext(ctx, req), client, req, pathParams)
if err != nil {
runtime.HTTPError(ctx, w, err)
return
}
forward_Slack_Invite_0(ctx, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
示例7: RegisterABitOfEverythingServiceHandler
// RegisterABitOfEverythingServiceHandler registers the http handlers for service ABitOfEverythingService to "mux".
// The handlers forward requests to the grpc endpoint over "conn".
func RegisterABitOfEverythingServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
client := NewABitOfEverythingServiceClient(conn)
mux.Handle("POST", pattern_ABitOfEverythingService_Create_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
resp, err := request_ABitOfEverythingService_Create_0(runtime.AnnotateContext(ctx, req), client, req, pathParams)
if err != nil {
runtime.HTTPError(ctx, w, err)
return
}
forward_ABitOfEverythingService_Create_0(ctx, w, req, resp)
})
mux.Handle("POST", pattern_ABitOfEverythingService_CreateBody_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
resp, err := request_ABitOfEverythingService_CreateBody_0(runtime.AnnotateContext(ctx, req), client, req, pathParams)
if err != nil {
runtime.HTTPError(ctx, w, err)
return
}
forward_ABitOfEverythingService_CreateBody_0(ctx, w, req, resp)
})
mux.Handle("POST", pattern_ABitOfEverythingService_BulkCreate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
resp, err := request_ABitOfEverythingService_BulkCreate_0(runtime.AnnotateContext(ctx, req), client, req, pathParams)
if err != nil {
runtime.HTTPError(ctx, w, err)
return
}
forward_ABitOfEverythingService_BulkCreate_0(ctx, w, req, resp)
})
mux.Handle("GET", pattern_ABitOfEverythingService_Lookup_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
resp, err := request_ABitOfEverythingService_Lookup_0(runtime.AnnotateContext(ctx, req), client, req, pathParams)
if err != nil {
runtime.HTTPError(ctx, w, err)
return
}
forward_ABitOfEverythingService_Lookup_0(ctx, w, req, resp)
})
mux.Handle("GET", pattern_ABitOfEverythingService_List_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
resp, err := request_ABitOfEverythingService_List_0(runtime.AnnotateContext(ctx, req), client, req, pathParams)
if err != nil {
runtime.HTTPError(ctx, w, err)
return
}
forward_ABitOfEverythingService_List_0(ctx, w, req, func() (proto.Message, error) { return resp.Recv() })
})
mux.Handle("PUT", pattern_ABitOfEverythingService_Update_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
resp, err := request_ABitOfEverythingService_Update_0(runtime.AnnotateContext(ctx, req), client, req, pathParams)
if err != nil {
runtime.HTTPError(ctx, w, err)
return
}
forward_ABitOfEverythingService_Update_0(ctx, w, req, resp)
})
mux.Handle("DELETE", pattern_ABitOfEverythingService_Delete_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
resp, err := request_ABitOfEverythingService_Delete_0(runtime.AnnotateContext(ctx, req), client, req, pathParams)
if err != nil {
runtime.HTTPError(ctx, w, err)
return
}
forward_ABitOfEverythingService_Delete_0(ctx, w, req, resp)
})
mux.Handle("GET", pattern_ABitOfEverythingService_Echo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
resp, err := request_ABitOfEverythingService_Echo_0(runtime.AnnotateContext(ctx, req), client, req, pathParams)
if err != nil {
runtime.HTTPError(ctx, w, err)
return
}
forward_ABitOfEverythingService_Echo_0(ctx, w, req, resp)
})
mux.Handle("POST", pattern_ABitOfEverythingService_Echo_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
resp, err := request_ABitOfEverythingService_Echo_1(runtime.AnnotateContext(ctx, req), client, req, pathParams)
if err != nil {
runtime.HTTPError(ctx, w, err)
return
}
//.........這裏部分代碼省略.........
示例8: RegisterFlowCombinationHandler
// RegisterFlowCombinationHandler registers the http handlers for service FlowCombination to "mux".
// The handlers forward requests to the grpc endpoint over "conn".
func RegisterFlowCombinationHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
client := NewFlowCombinationClient(conn)
mux.Handle("POST", pattern_FlowCombination_RpcEmptyRpc_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
resp, err := request_FlowCombination_RpcEmptyRpc_0(runtime.AnnotateContext(ctx, req), client, req, pathParams)
if err != nil {
runtime.HTTPError(ctx, w, err)
return
}
forward_FlowCombination_RpcEmptyRpc_0(ctx, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("POST", pattern_FlowCombination_RpcEmptyStream_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
resp, err := request_FlowCombination_RpcEmptyStream_0(runtime.AnnotateContext(ctx, req), client, req, pathParams)
if err != nil {
runtime.HTTPError(ctx, w, err)
return
}
forward_FlowCombination_RpcEmptyStream_0(ctx, w, req, func() (proto.Message, error) { return resp.Recv() }, mux.GetForwardResponseOptions()...)
})
mux.Handle("POST", pattern_FlowCombination_StreamEmptyRpc_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
resp, err := request_FlowCombination_StreamEmptyRpc_0(runtime.AnnotateContext(ctx, req), client, req, pathParams)
if err != nil {
runtime.HTTPError(ctx, w, err)
return
}
forward_FlowCombination_StreamEmptyRpc_0(ctx, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("POST", pattern_FlowCombination_StreamEmptyStream_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
resp, err := request_FlowCombination_StreamEmptyStream_0(runtime.AnnotateContext(ctx, req), client, req, pathParams)
if err != nil {
runtime.HTTPError(ctx, w, err)
return
}
forward_FlowCombination_StreamEmptyStream_0(ctx, w, req, func() (proto.Message, error) { return resp.Recv() }, mux.GetForwardResponseOptions()...)
})
mux.Handle("POST", pattern_FlowCombination_RpcBodyRpc_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
resp, err := request_FlowCombination_RpcBodyRpc_0(runtime.AnnotateContext(ctx, req), client, req, pathParams)
if err != nil {
runtime.HTTPError(ctx, w, err)
return
}
forward_FlowCombination_RpcBodyRpc_0(ctx, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("POST", pattern_FlowCombination_RpcBodyRpc_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
resp, err := request_FlowCombination_RpcBodyRpc_1(runtime.AnnotateContext(ctx, req), client, req, pathParams)
if err != nil {
runtime.HTTPError(ctx, w, err)
return
}
forward_FlowCombination_RpcBodyRpc_1(ctx, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("POST", pattern_FlowCombination_RpcBodyRpc_2, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
resp, err := request_FlowCombination_RpcBodyRpc_2(runtime.AnnotateContext(ctx, req), client, req, pathParams)
if err != nil {
runtime.HTTPError(ctx, w, err)
return
}
forward_FlowCombination_RpcBodyRpc_2(ctx, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("POST", pattern_FlowCombination_RpcBodyRpc_3, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
resp, err := request_FlowCombination_RpcBodyRpc_3(runtime.AnnotateContext(ctx, req), client, req, pathParams)
if err != nil {
runtime.HTTPError(ctx, w, err)
return
}
forward_FlowCombination_RpcBodyRpc_3(ctx, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("POST", pattern_FlowCombination_RpcBodyRpc_4, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
resp, err := request_FlowCombination_RpcBodyRpc_4(runtime.AnnotateContext(ctx, req), client, req, pathParams)
if err != nil {
runtime.HTTPError(ctx, w, err)
return
}
//.........這裏部分代碼省略.........
示例9: RegisterAdminHandler
// RegisterAdminHandler registers the http handlers for service Admin to "mux".
// The handlers forward requests to the grpc endpoint over "conn".
func RegisterAdminHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
client := NewAdminClient(conn)
mux.Handle("GET", pattern_Admin_Users_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(ctx)
defer cancel()
if cn, ok := w.(http.CloseNotifier); ok {
go func(done <-chan struct{}, closed <-chan bool) {
select {
case <-done:
case <-closed:
cancel()
}
}(ctx.Done(), cn.CloseNotify())
}
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, req)
if err != nil {
runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
}
resp, md, err := request_Admin_Users_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
return
}
forward_Admin_Users_0(ctx, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_Admin_Databases_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(ctx)
defer cancel()
if cn, ok := w.(http.CloseNotifier); ok {
go func(done <-chan struct{}, closed <-chan bool) {
select {
case <-done:
case <-closed:
cancel()
}
}(ctx.Done(), cn.CloseNotify())
}
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, req)
if err != nil {
runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
}
resp, md, err := request_Admin_Databases_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
return
}
forward_Admin_Databases_0(ctx, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_Admin_DatabaseDetails_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(ctx)
defer cancel()
if cn, ok := w.(http.CloseNotifier); ok {
go func(done <-chan struct{}, closed <-chan bool) {
select {
case <-done:
case <-closed:
cancel()
}
}(ctx.Done(), cn.CloseNotify())
}
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, req)
if err != nil {
runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
}
resp, md, err := request_Admin_DatabaseDetails_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
return
}
forward_Admin_DatabaseDetails_0(ctx, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_Admin_TableDetails_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(ctx)
defer cancel()
if cn, ok := w.(http.CloseNotifier); ok {
go func(done <-chan struct{}, closed <-chan bool) {
select {
case <-done:
case <-closed:
cancel()
}
}(ctx.Done(), cn.CloseNotify())
//.........這裏部分代碼省略.........
示例10: RegisterAPIHandler
// RegisterAPIHandler registers the http handlers for service API to "mux".
// The handlers forward requests to the grpc endpoint over "conn".
func RegisterAPIHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
client := NewAPIClient(conn)
mux.Handle("GET", pattern_API_GetAirport_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
resp, err := request_API_GetAirport_0(runtime.AnnotateContext(ctx, req), client, req, pathParams)
if err != nil {
runtime.HTTPError(ctx, w, req, err)
return
}
forward_API_GetAirport_0(ctx, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_API_GetAirline_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
resp, err := request_API_GetAirline_0(runtime.AnnotateContext(ctx, req), client, req, pathParams)
if err != nil {
runtime.HTTPError(ctx, w, req, err)
return
}
forward_API_GetAirline_0(ctx, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_API_GetRoutes_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
resp, err := request_API_GetRoutes_0(runtime.AnnotateContext(ctx, req), client, req, pathParams)
if err != nil {
runtime.HTTPError(ctx, w, req, err)
return
}
forward_API_GetRoutes_0(ctx, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_API_GetDistance_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
resp, err := request_API_GetDistance_0(runtime.AnnotateContext(ctx, req), client, req, pathParams)
if err != nil {
runtime.HTTPError(ctx, w, req, err)
return
}
forward_API_GetDistance_0(ctx, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_API_GetMiles_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
resp, err := request_API_GetMiles_0(runtime.AnnotateContext(ctx, req), client, req, pathParams)
if err != nil {
runtime.HTTPError(ctx, w, req, err)
return
}
forward_API_GetMiles_0(ctx, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("POST", pattern_API_GetMiles_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
resp, err := request_API_GetMiles_1(runtime.AnnotateContext(ctx, req), client, req, pathParams)
if err != nil {
runtime.HTTPError(ctx, w, req, err)
return
}
forward_API_GetMiles_1(ctx, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
示例11: RegisterABitOfEverythingServiceHandler
// RegisterABitOfEverythingServiceHandler registers the http handlers for service ABitOfEverythingService to "mux".
// The handlers forward requests to the grpc endpoint over "conn".
func RegisterABitOfEverythingServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
client := NewABitOfEverythingServiceClient(conn)
mux.Handle("POST", pattern_ABitOfEverythingService_Create_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(ctx)
closeNotifier, ok := w.(http.CloseNotifier)
if ok {
go func() {
<-closeNotifier.CloseNotify()
cancel()
}()
}
resp, err := request_ABitOfEverythingService_Create_0(runtime.AnnotateContext(ctx, req), client, req, pathParams)
if err != nil {
runtime.HTTPError(ctx, w, req, err)
return
}
forward_ABitOfEverythingService_Create_0(ctx, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("POST", pattern_ABitOfEverythingService_CreateBody_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(ctx)
closeNotifier, ok := w.(http.CloseNotifier)
if ok {
go func() {
<-closeNotifier.CloseNotify()
cancel()
}()
}
resp, err := request_ABitOfEverythingService_CreateBody_0(runtime.AnnotateContext(ctx, req), client, req, pathParams)
if err != nil {
runtime.HTTPError(ctx, w, req, err)
return
}
forward_ABitOfEverythingService_CreateBody_0(ctx, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("POST", pattern_ABitOfEverythingService_BulkCreate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(ctx)
closeNotifier, ok := w.(http.CloseNotifier)
if ok {
go func() {
<-closeNotifier.CloseNotify()
cancel()
}()
}
resp, err := request_ABitOfEverythingService_BulkCreate_0(runtime.AnnotateContext(ctx, req), client, req, pathParams)
if err != nil {
runtime.HTTPError(ctx, w, req, err)
return
}
forward_ABitOfEverythingService_BulkCreate_0(ctx, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_ABitOfEverythingService_Lookup_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(ctx)
closeNotifier, ok := w.(http.CloseNotifier)
if ok {
go func() {
<-closeNotifier.CloseNotify()
cancel()
}()
}
resp, err := request_ABitOfEverythingService_Lookup_0(runtime.AnnotateContext(ctx, req), client, req, pathParams)
if err != nil {
runtime.HTTPError(ctx, w, req, err)
return
}
forward_ABitOfEverythingService_Lookup_0(ctx, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_ABitOfEverythingService_List_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(ctx)
closeNotifier, ok := w.(http.CloseNotifier)
if ok {
go func() {
<-closeNotifier.CloseNotify()
cancel()
}()
}
resp, err := request_ABitOfEverythingService_List_0(runtime.AnnotateContext(ctx, req), client, req, pathParams)
if err != nil {
runtime.HTTPError(ctx, w, req, err)
return
}
forward_ABitOfEverythingService_List_0(ctx, w, req, func() (proto.Message, error) { return resp.Recv() }, mux.GetForwardResponseOptions()...)
})
//.........這裏部分代碼省略.........
示例12: RegisterApiHandler
// RegisterApiHandler registers the http handlers for service Api to "mux".
// The handlers forward requests to the grpc endpoint over "conn".
func RegisterApiHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
client := NewApiClient(conn)
mux.Handle("POST", pattern_Api_InitRepository_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
resp, err := request_Api_InitRepository_0(runtime.AnnotateContext(ctx, req), client, req, pathParams)
if err != nil {
runtime.HTTPError(ctx, w, err)
return
}
forward_Api_InitRepository_0(ctx, w, req, resp)
})
mux.Handle("GET", pattern_Api_ListRepositories_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
resp, err := request_Api_ListRepositories_0(runtime.AnnotateContext(ctx, req), client, req, pathParams)
if err != nil {
runtime.HTTPError(ctx, w, err)
return
}
forward_Api_ListRepositories_0(ctx, w, req, resp)
})
mux.Handle("GET", pattern_Api_GetFile_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
resp, err := request_Api_GetFile_0(runtime.AnnotateContext(ctx, req), client, req, pathParams)
if err != nil {
runtime.HTTPError(ctx, w, err)
return
}
forward_Api_GetFile_0(ctx, w, req, func() (proto.Message, error) { return resp.Recv() })
})
mux.Handle("GET", pattern_Api_GetFileInfo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
resp, err := request_Api_GetFileInfo_0(runtime.AnnotateContext(ctx, req), client, req, pathParams)
if err != nil {
runtime.HTTPError(ctx, w, err)
return
}
forward_Api_GetFileInfo_0(ctx, w, req, resp)
})
mux.Handle("POST", pattern_Api_MakeDirectory_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
resp, err := request_Api_MakeDirectory_0(runtime.AnnotateContext(ctx, req), client, req, pathParams)
if err != nil {
runtime.HTTPError(ctx, w, err)
return
}
forward_Api_MakeDirectory_0(ctx, w, req, resp)
})
mux.Handle("POST", pattern_Api_PutFile_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
resp, err := request_Api_PutFile_0(runtime.AnnotateContext(ctx, req), client, req, pathParams)
if err != nil {
runtime.HTTPError(ctx, w, err)
return
}
forward_Api_PutFile_0(ctx, w, req, resp)
})
mux.Handle("GET", pattern_Api_ListFiles_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
resp, err := request_Api_ListFiles_0(runtime.AnnotateContext(ctx, req), client, req, pathParams)
if err != nil {
runtime.HTTPError(ctx, w, err)
return
}
forward_Api_ListFiles_0(ctx, w, req, resp)
})
mux.Handle("POST", pattern_Api_Branch_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
resp, err := request_Api_Branch_0(runtime.AnnotateContext(ctx, req), client, req, pathParams)
if err != nil {
runtime.HTTPError(ctx, w, err)
return
}
forward_Api_Branch_0(ctx, w, req, resp)
})
mux.Handle("POST", pattern_Api_Write_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
resp, err := request_Api_Write_0(runtime.AnnotateContext(ctx, req), client, req, pathParams)
if err != nil {
runtime.HTTPError(ctx, w, err)
return
}
//.........這裏部分代碼省略.........
示例13: RegisterAPIHandler
// RegisterAPIHandler registers the http handlers for service API to "mux".
// The handlers forward requests to the grpc endpoint over "conn".
func RegisterAPIHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
client := NewAPIClient(conn)
mux.Handle("POST", pattern_API_Create_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
resp, err := request_API_Create_0(runtime.AnnotateContext(ctx, req), client, req, pathParams)
if err != nil {
runtime.HTTPError(ctx, w, err)
return
}
forward_API_Create_0(ctx, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("POST", pattern_API_Remove_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
resp, err := request_API_Remove_0(runtime.AnnotateContext(ctx, req), client, req, pathParams)
if err != nil {
runtime.HTTPError(ctx, w, err)
return
}
forward_API_Remove_0(ctx, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("POST", pattern_API_Path_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
resp, err := request_API_Path_0(runtime.AnnotateContext(ctx, req), client, req, pathParams)
if err != nil {
runtime.HTTPError(ctx, w, err)
return
}
forward_API_Path_0(ctx, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("POST", pattern_API_Mount_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
resp, err := request_API_Mount_0(runtime.AnnotateContext(ctx, req), client, req, pathParams)
if err != nil {
runtime.HTTPError(ctx, w, err)
return
}
forward_API_Mount_0(ctx, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("POST", pattern_API_Unmount_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
resp, err := request_API_Unmount_0(runtime.AnnotateContext(ctx, req), client, req, pathParams)
if err != nil {
runtime.HTTPError(ctx, w, err)
return
}
forward_API_Unmount_0(ctx, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_API_Cleanup_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
resp, err := request_API_Cleanup_0(runtime.AnnotateContext(ctx, req), client, req, pathParams)
if err != nil {
runtime.HTTPError(ctx, w, err)
return
}
forward_API_Cleanup_0(ctx, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_API_GetVolume_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
resp, err := request_API_GetVolume_0(runtime.AnnotateContext(ctx, req), client, req, pathParams)
if err != nil {
runtime.HTTPError(ctx, w, err)
return
}
forward_API_GetVolume_0(ctx, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_API_ListVolumes_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
resp, err := request_API_ListVolumes_0(runtime.AnnotateContext(ctx, req), client, req, pathParams)
if err != nil {
runtime.HTTPError(ctx, w, err)
return
}
forward_API_ListVolumes_0(ctx, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
示例14: RegisterABitOfEverythingServiceHandler
// RegisterABitOfEverythingServiceHandler registers the http handlers for service ABitOfEverythingService to "mux".
// The handlers forward requests to the grpc endpoint over "conn".
func RegisterABitOfEverythingServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
client := NewABitOfEverythingServiceClient(conn)
mux.Handle("POST", pattern_ABitOfEverythingService_Create_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(ctx)
defer cancel()
if cn, ok := w.(http.CloseNotifier); ok {
go func(done <-chan struct{}, closed <-chan bool) {
select {
case <-done:
case <-closed:
cancel()
}
}(ctx.Done(), cn.CloseNotify())
}
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, req)
if err != nil {
runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
}
resp, md, err := request_ABitOfEverythingService_Create_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
return
}
forward_ABitOfEverythingService_Create_0(ctx, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("POST", pattern_ABitOfEverythingService_CreateBody_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(ctx)
defer cancel()
if cn, ok := w.(http.CloseNotifier); ok {
go func(done <-chan struct{}, closed <-chan bool) {
select {
case <-done:
case <-closed:
cancel()
}
}(ctx.Done(), cn.CloseNotify())
}
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, req)
if err != nil {
runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
}
resp, md, err := request_ABitOfEverythingService_CreateBody_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
return
}
forward_ABitOfEverythingService_CreateBody_0(ctx, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_ABitOfEverythingService_Lookup_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(ctx)
defer cancel()
if cn, ok := w.(http.CloseNotifier); ok {
go func(done <-chan struct{}, closed <-chan bool) {
select {
case <-done:
case <-closed:
cancel()
}
}(ctx.Done(), cn.CloseNotify())
}
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, req)
if err != nil {
runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
}
resp, md, err := request_ABitOfEverythingService_Lookup_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
return
}
forward_ABitOfEverythingService_Lookup_0(ctx, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("PUT", pattern_ABitOfEverythingService_Update_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(ctx)
defer cancel()
if cn, ok := w.(http.CloseNotifier); ok {
go func(done <-chan struct{}, closed <-chan bool) {
select {
case <-done:
case <-closed:
cancel()
}
}(ctx.Done(), cn.CloseNotify())
//.........這裏部分代碼省略.........