1
0
mirror of https://github.com/go-kratos/kratos.git synced 2025-03-17 21:07:54 +02:00

clean examples (#1041)

* clean examples
This commit is contained in:
Tony Chen 2021-06-13 08:42:26 +08:00 committed by GitHub
parent 99719dd667
commit 40e34b32f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 9 deletions

5
app.go
View File

@ -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

View File

@ -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)
}

View File

@ -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(