hello

package
v2.1.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2018 License: MIT Imports: 4 Imported by: 0

README

Example Service: hello

A simple example service that demonstrates how to use a Hoster instance to host a service with gRPC and HTTP endpoints.

Prerequisites

  • Install gRPC
    • Make sure protoc is in GOPATH/bin
    • Make sure google/protobuf is also in GOPATH/bin
  • Install grpc-gateway

Run the server

  • Insecure
    • go run cmd/server/main.go
  • With TLS
    • go run cmd/server/main.go -cert-file ../../testdata/test.crt -key-file ../../testdata/test.key -insecure-skip-verify

NOTE: insecure-skip-verify is only used for testing when the host name does not need to be verified and should not be used in production.

Test the gRPC endpoint with the command-line client

  • Insecure
    • go run cmd/client/main.go -insecure -name eleniums
  • With TLS
    • go run cmd/client/main.go -insecure-skip-verify -name eleniums

Test the HTTP endpoint with curl

  • Insecure
    • curl http://127.0.0.1:9090/v1/hello?name=eleniums
  • With TLS
    • curl -k https://127.0.0.1:9090/v1/hello?name=eleniums

Test the debug endpoint

Regenerate client/server from proto

  • Use go:generate to build client/server and swagger docs:
    • go generate

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Service

type Service struct{}

Service contains the implementation for the gRPC service.

func NewService

func NewService() *Service

NewService creates a new instance of Service.

func (*Service) Hello

func (s *Service) Hello(ctx context.Context, in *pb.HelloRequest) (*pb.HelloResponse, error)

Hello will return a personalized greeting.

Directories

Path Synopsis
cmd
Package hello is a generated protocol buffer package.
Package hello is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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