mirror of
https://github.com/go-kratos/kratos.git
synced 2025-01-16 02:47:03 +02:00
b9f821c29f
* add http handler * fix request error
25 lines
438 B
Go
25 lines
438 B
Go
package http
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
)
|
|
|
|
type HelloRequest struct {
|
|
Name string `json:"name"`
|
|
}
|
|
type HelloReply struct {
|
|
Message string `json:"message"`
|
|
}
|
|
type GreeterService struct {
|
|
}
|
|
|
|
func (s *GreeterService) SayHello(ctx context.Context, req *HelloRequest) (*HelloReply, error) {
|
|
return &HelloReply{Message: "hello " + req.Name}, nil
|
|
}
|
|
|
|
func TestHandler(t *testing.T) {
|
|
s := &GreeterService{}
|
|
_ = NewHandler(s.SayHello)
|
|
}
|