profile

package
v0.0.0-...-577d994 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 10, 2017 License: MIT Imports: 12 Imported by: 0

README

gRPC Gateway Sample

This is a sample of gRPC Gateway.

Pre installed

It assumes that you have read the Project Root README and followed the instruction.

Install another plugins for protoc.

$ go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway
$ go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger

Proto file

How to convert

Stub
$ protoc -I. \
    -I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
    --go_out=plugins=grpc:. \
    *.proto

This will generate a stub profile.pb.go.

Gateway
$ protoc -I. \
    -I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
    --grpc-gateway_out=logtostderr=true:. \
    *.proto

This will generate a stub profile.pb.gw.go.

Implementation

Test

# Launch.
$ go run server/main.go
$ go run gateway/main.go

# Test.
$ curl -d '{"value":"aaa"}' http://localhost:8080/v1/example/echo
{"value":"aaa"}

More examples

https://github.com/grpc-ecosystem/grpc-gateway/tree/master/examples

References

https://github.com/grpc-ecosystem/grpc-gateway

Documentation

Overview

Package profile is a generated protocol buffer package.

It is generated from these files:

echo.proto

It has these top-level messages:

StringMessage

Package profile is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterProfileHandler

func RegisterProfileHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error

RegisterProfileHandler registers the http handlers for service Profile to "mux". The handlers forward requests to the grpc endpoint over "conn".

func RegisterProfileHandlerFromEndpoint

func RegisterProfileHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)

RegisterProfileHandlerFromEndpoint is same as RegisterProfileHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.

func RegisterProfileServer

func RegisterProfileServer(s *grpc.Server, srv ProfileServer)

Types

type ProfileClient

type ProfileClient interface {
	//    rpc Echo(StringMessage) returns (StringMessage) {}
	Echo(ctx context.Context, in *StringMessage, opts ...grpc.CallOption) (*StringMessage, error)
}

func NewProfileClient

func NewProfileClient(cc *grpc.ClientConn) ProfileClient

type ProfileServer

type ProfileServer interface {
	//    rpc Echo(StringMessage) returns (StringMessage) {}
	Echo(context.Context, *StringMessage) (*StringMessage, error)
}

type StringMessage

type StringMessage struct {
	Value string `protobuf:"bytes,1,opt,name=value" json:"value,omitempty"`
}

func (*StringMessage) Descriptor

func (*StringMessage) Descriptor() ([]byte, []int)

func (*StringMessage) GetValue

func (m *StringMessage) GetValue() string

func (*StringMessage) ProtoMessage

func (*StringMessage) ProtoMessage()

func (*StringMessage) Reset

func (m *StringMessage) Reset()

func (*StringMessage) String

func (m *StringMessage) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL