MCPcopy Create free account
hub / github.com/apache/dubbo-go / Example_handler

Function Example_handler

protocol/triple/triple_protocol/handler_example_test.go:46–72  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

44}
45
46func Example_handler() {
47 // protoc-gen-triple-go generates constructors that return plain net/http
48 // Handlers, so they're compatible with most Go HTTP routers and middleware
49 // (for example, net/http's StripPrefix). Each handler automatically supports
50 // the Connect, gRPC, and gRPC-Web protocols.
51 mux := http.NewServeMux()
52 mux.Handle(
53 pingv1connect.NewPingServiceHandler(
54 &ExamplePingServer{}, // our business logic
55 ),
56 )
57 // You can serve gRPC's health and server reflection APIs using
58 // github.com/bufbuild/triple-grpchealth-go and
59 // github.com/bufbuild/triple-grpcreflect-go.
60 _ = http.ListenAndServeTLS(
61 "localhost:8080",
62 "internal/testdata/server.crt",
63 "internal/testdata/server.key",
64 mux,
65 )
66 // To serve HTTP/2 requests without TLS (as many gRPC clients expect), import
67 // golang.org/x/net/http2/h2c and golang.org/x/net/http2 and change to:
68 // _ = http.ListenAndServe(
69 // "localhost:8080",
70 // h2c.NewHandler(mux, &http2.Server{}),
71 // )
72}

Callers

nothing calls this directly

Calls 2

NewPingServiceHandlerFunction · 0.92
HandleMethod · 0.45

Tested by

no test coverage detected