genrest

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2021 License: Apache-2.0 Imports: 15 Imported by: 0

README

util/genrest

This directory contains the core functionality for the protoc plugin go_rest_server, which implements a REST endpoint for Showcase services.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Generate

func Generate(plugin *protogen.Plugin) error

func NewGoModel

func NewGoModel(protoModel *protomodel.Model) (*gomodel.Model, error)

NewGoModel creates a new goModel.Model from the given protomodel.Model. It essentially extracts and organizes the data needed to later generate Go source files.

func NewProtoModel

func NewProtoModel(plugin *protogen.Plugin) (*protomodel.Model, error)

NewProtoModel uses the information in `plugin` to create a new protomodel.Model.

func NewRESTBinding

func NewRESTBinding(methodName string, rule *annotations.HttpRule, index int) (*protomodel.RESTBinding, error)

NewRESTBinding creates a new protomodel.RESTBinding using the given methodName, rule, and index.

func NewRESTRequestPattern

func NewRESTRequestPattern(rule *annotations.HttpRule) (*protomodel.RESTRequestPattern, error)

NewRESTRequestPattern creates a new protomodel.RESTRequestPattern by analyzing the rule provided.

func NewService

func NewService(protoPackage string, descriptor *descriptorpb.ServiceDescriptorProto) *protomodel.Service

NewService creates a protomodel.Service from the given descriptor.

func NewServiceBinding

func NewServiceBinding(service *protomodel.Service, method *descriptor.MethodDescriptorProto, rule *annotations.HttpRule, index int) error

NewServiceBinding adds `rule` (as the `index`th binding for `method`) to the specified `service`.

func NewView

func NewView(model *gomodel.Model) (*goview.View, error)

NewView creates a a new goview.View (a series of files to be output) from a gomodel.Model. The current approach is to generate one file per service, with that file containing all the service's RPCs. An additional file `genrest.go` is also created to register all these handlers with a gorilla/mux dispatcher.

Types

type Namer

type Namer struct {
	// contains filtered or unexported fields
}

Namer keeps track of a series of symbol names being used in order to disambiguate new names.

func NewNamer

func NewNamer() *Namer

NewNamer returns a new Namer.

func (*Namer) Get

func (namer *Namer) Get(newName string) string

Get registers and returns a non-previously registered name that is as close to newName as possible. Disambiguation, if needed, is accomplished by adding a numeric suffix.

Directories

Path Synopsis
internal
pbinfo
Package pbinfo provides convenience types for looking up protobuf elements.
Package pbinfo provides convenience types for looking up protobuf elements.

Jump to

Keyboard shortcuts

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