Skip to content
Permalink
Browse files

服务创建

  • Loading branch information...
hb-chen committed Oct 13, 2019
1 parent 4a7b153 commit e76368bbee7dec646d13f1d9644b9d529e88074f
@@ -5,7 +5,8 @@ import (

"github.com/micro/go-micro"
"github.com/micro/go-micro/server"
"path/to/service/proto/example"

example "github.com/hb-go/micro-quick-start/example/srv/proto/example"
)

type exampleKey struct{}
@@ -18,7 +19,7 @@ func ExampleFromContext(ctx context.Context) (example.ExampleService, bool) {

// Client returns a wrapper for the ExampleClient
func ExampleWrapper(service micro.Service) server.HandlerWrapper {
client := example.NewExampleService("go.micro.srv.template", service.Client())
client := example.NewExampleService("go.micro.srv.example", service.Client())

return func(fn server.HandlerFunc) server.HandlerFunc {
return func(ctx context.Context, req server.Request, rsp interface{}) error {

This file was deleted.

@@ -8,7 +8,8 @@ import (
"github.com/hb-go/micro-quick-start/example/api/client"
api "github.com/micro/go-micro/api/proto"
"github.com/micro/go-micro/errors"
"path/to/service/proto/example"

example "github.com/hb-go/micro-quick-start/example/srv/proto/example"
)

type Example struct{}
@@ -7,7 +7,10 @@ import (
"github.com/hb-go/micro-quick-start/example/api/handler"
"github.com/micro/go-micro"

"github.com/hb-go/micro-quick-start/example/api/proto/example"
"github.com/micro/go-micro/api"
ha "github.com/micro/go-micro/api/handler/api"

example "github.com/hb-go/micro-quick-start/example/api/proto/example"
)

func main() {
@@ -24,7 +27,19 @@ func main() {
)

// Register Handler
example.RegisterExampleHandler(service.Server(), new(handler.Example))
example.RegisterExampleHandler(
service.Server(),
new(handler.Example),
api.WithEndpoint(&api.Endpoint{
// The RPC method
Name: "Example.Call",
// The HTTP paths. This can be a POSIX regex
Path: []string{"/example/call"},
// The HTTP Methods for this endpoint
Method: []string{"GET", "POST"},
Handler: ha.Handler,
}),
)

// Run service
if err := service.Run(); err != nil {

Some generated files are not rendered by default. Learn more.

Some generated files are not rendered by default. Learn more.

This file was deleted.

@@ -5,7 +5,7 @@ import (

"github.com/micro/go-micro/util/log"

"github.com/hb-go/micro-quick-start/example/srv/proto/example"
example "github.com/hb-go/micro-quick-start/example/srv/proto/example"
)

type Example struct{}
@@ -6,7 +6,7 @@ import (
"github.com/micro/go-micro"
"github.com/micro/go-micro/util/log"

"github.com/hb-go/micro-quick-start/example/srv/proto/example"
example "github.com/hb-go/micro-quick-start/example/srv/proto/example"
)

func main() {

0 comments on commit e76368b

Please sign in to comment.
You can’t perform that action at this time.