clean examples (#1041)

* clean examples
pull/1044/head
Tony Chen 3 years ago committed by GitHub
parent 99719dd667
commit 40e34b32f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      app.go
  2. 8
      examples/metadata/client/main.go
  3. 4
      examples/ws/main.go

@ -49,11 +49,6 @@ func New(opts ...Option) *App {
// Run executes all OnStart hooks registered with the application's Lifecycle.
func (a *App) Run() error {
a.log.Infow(
"service_id", a.opts.id,
"service_name", a.opts.name,
"service_version", a.opts.version,
)
instance, err := a.buildInstance()
if err != nil {
return err

@ -30,8 +30,12 @@ func callHTTP() {
panic(err)
}
client := helloworld.NewGreeterHTTPClient(conn)
md := metadata.New(map[string][]string{"kratos-extra": {"2233"}})
reply, err := client.SayHello(context.Background(), &helloworld.HelloRequest{Name: "kratos"}, http.Metadata(md))
md := metadata.Metadata{"kratos-extra": "2233"}
reply, err := client.SayHello(context.Background(),
&helloworld.HelloRequest{Name: "kratos"},
// call options
http.Metadata(md),
)
if err != nil {
log.Fatal(err)
}

@ -5,7 +5,7 @@ import (
"github.com/go-kratos/kratos/examples/ws/handler"
"github.com/go-kratos/kratos/v2"
transhttp "github.com/go-kratos/kratos/v2/transport/http"
"github.com/go-kratos/kratos/v2/transport/http"
"github.com/gorilla/mux"
)
@ -13,7 +13,7 @@ func main() {
router := mux.NewRouter()
router.HandleFunc("/ws", handler.WsHandler)
httpSrv := transhttp.NewServer(transhttp.Address(":8080"))
httpSrv := http.NewServer(http.Address(":8080"))
httpSrv.HandlePrefix("/", router)
app := kratos.New(

Loading…
Cancel
Save