mirror of
https://github.com/go-kratos/kratos.git
synced 2025-03-17 21:07:54 +02:00
parent
99719dd667
commit
40e34b32f1
5
app.go
5
app.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…
x
Reference in New Issue
Block a user