Documentation ¶
Index ¶
- Constants
- Variables
- func CamelCase(s string) string
- func ParsePath(p string) []string
- func Sanitize(s string) string
- type ByKey
- type Enum
- type EnumValue
- type Enums
- type Field
- type FieldMetadata
- type FieldMetadatas
- type Fields
- type File
- type Files
- type Message
- type Messages
- type Method
- func (m *Method) FullName() string
- func (m *Method) HarmonizedRESTPath() string
- func (m *Method) HasBodyMapping() bool
- func (m *Method) HasMethodMap() bool
- func (m *Method) HasPathParamsMapping() bool
- func (m *Method) HasQueryStringMapping() bool
- func (m *Method) InputTypeName() string
- func (m *Method) OutputTypeName() string
- type Methods
- type PathParam
- type PathParams
- type QSParameter
- type QueryStringKV
- type QueryStringParam
- type QueryStringParams
- type Registry
- type Service
- type SortedParsedQueryString
Constants ¶
const OptionDartPackage = "dart_package"
Variables ¶
var ReservedNames = []string{"Reset", "String", "ProtoMessage", "Descriptor"}
ReservedNames are reserved by Protobuf and therefore cannot be field names (Protobuf generates methods with those names).
Functions ¶
func CamelCase ¶
CamelCase converts a snake_cased (_) identifier to an CamelCased identifier (hello_world -> HelloWorld) From the golang/protobuf
Types ¶
type ByKey ¶
type ByKey SortedParsedQueryString
ByAge implements sort.Interface for []Person based on the Age field.
type Enum ¶
type Enum struct { Type *descriptorpb.EnumDescriptorProto File *File Registry *Registry Filename string Package string Comment string Index int Name string Values []*EnumValue }
func NewEnum ¶
func NewEnum(d *descriptorpb.EnumDescriptorProto, f *File, index int) *Enum
type EnumValue ¶
type EnumValue struct { Type *descriptorpb.EnumValueDescriptorProto Enum *Enum Name string Number int32 Registry *Registry }
func NewEnumValue ¶
func NewEnumValue(d *descriptorpb.EnumValueDescriptorProto, e *Enum, r *Registry) *EnumValue
type Field ¶
type Field struct { Type *descriptorpb.FieldDescriptorProto // Is used for maps. A map is a nested type in protobuf. This nested type is only accessible via the descriptorpb.DescriptorProto Message *Message Registry *Registry Name string IsComplex bool }
Field represents the information about a field in a message at the moment just a simple wrapper for easier access and a reference to the Registry
func NewField ¶
func NewField(f *descriptorpb.FieldDescriptorProto, m *Message, r *Registry) *Field
NewField instantiates a new Field
func (*Field) IsIntermediateMap ¶
func (*Field) IsRepeated ¶
IsRepeated returns true, if the protobuf field is repated
type FieldMetadata ¶
type FieldMetadata struct { Type string ProtoKind descriptorpb.FieldDescriptorProto_Type Name string }
FieldMetadata holds Information needed to generate the code to copy a defined QueryString parameters to a actually field
func (*FieldMetadata) GetType ¶
func (f *FieldMetadata) GetType() string
GetType gets the type of the final field. Protobuf has a leading . which will be removed for being a proper go identifier
type FieldMetadatas ¶
type FieldMetadatas []FieldMetadata
FieldMetadatas are not part of the Registry. They represent a path to a field in the object tree. like r.User.Name.Firstname in a Protobuf Request.
func (*FieldMetadatas) Generate ¶
func (fmds *FieldMetadatas) Generate() string
Generate returns the go code to set a field value in an struct tree Since protobuf works with pointer intermediate structs have to be instantiated
func (*FieldMetadatas) GetPath ¶
func (fmds *FieldMetadatas) GetPath() string
GetPath returns the path to write out to set a value For example r.User.Name.Firstname
type File ¶
type File struct { Type *descriptorpb.FileDescriptorProto Name string Messages []*Message Enums []*Enum Package string Registry *Registry // Options holds additional options. For example our dart_package options Options map[string]string }
func NewFile ¶
func NewFile(f *descriptorpb.FileDescriptorProto, r *Registry) *File
type Message ¶
type Message struct { Type *descriptorpb.DescriptorProto File *File Registry *Registry Filename string Package string Comment string Index int Fields Fields }
Message wraps a protobuf message with a little extra information for code generation
func NewMessage ¶
func NewMessage(d *descriptorpb.DescriptorProto, f *File, index int) *Message
func (*Message) GetFieldType ¶
func (m *Message) GetFieldType(path string) *FieldMetadatas
GetFieldType returns the type of a field in the struct tree below the message
type Method ¶
type Method struct { Type *descriptorpb.MethodDescriptorProto Package string Name string RESTMethod string RESTPath string RESTPathVars PathParams RESTQueryString QueryStringParams RESTBody string InputType *descriptorpb.DescriptorProto OutputType *descriptorpb.DescriptorProto Registry *Registry // contains filtered or unexported fields }
Method is wrapper around the MethodDescriptorProto with some additional/extracted information useful to generate the Gateway
func (*Method) HarmonizedRESTPath ¶
HarmonizedRESTPath returns a cleaned-up version of Mapped REST-Path so it can be registered without conflicts to the router
func (*Method) HasBodyMapping ¶
HasBodyMapping returns true, if in the REST Mapping the requests body is mapped
func (*Method) HasMethodMap ¶
HasMethodMap returns true, if the method has a MethodMap options
func (*Method) HasPathParamsMapping ¶
HasPathParamsMapping returns true, if url-path parameters are mapped
func (*Method) HasQueryStringMapping ¶
HasQueryStringMapping returns true, if the Method has a Query String Mapping
func (*Method) InputTypeName ¶
InputTypeName retrurns the mame if the method's input type
func (*Method) OutputTypeName ¶
OutputTypeName returns the name of the method's output type
type PathParam ¶
type PathParam struct { N int FieldSanitized string FieldRaw string Metadata *FieldMetadatas }
PathParam collects information about the different URL path parameters.
func NewPathParam ¶
NewPathParam returns a correct PathParam value
type QSParameter ¶
type QSParameter struct { Key string // Which key Field string // goes to which field in a go struct Type string // should have what type Metadata *FieldMetadatas }
QSParameter represents the information of the mapping between parameters transported in the query string and how they map to a go struct
type QueryStringKV ¶
type QueryStringParam ¶
QueryStringParam is provides all the information nessesary for the code generation to map on query string parameter to a go field
type QueryStringParams ¶
type QueryStringParams []QSParameter
QueryStringParams is a collection of query string parameter definitions The Format of a Query string has the following format: "key1=<field1:type1>&key2=<field2:type1>" The <> around field:type can be omitted Semantic: The value for key1 will be mapped to the field field1 in a go struct and is expected to have type type1 Supported types are int, string, float, bool, bytes Bytes are expected to be in Base64-URL (RFC 4648 Section 5)
func NewQueryStringParams ¶
func NewQueryStringParams(definition string) (*QueryStringParams, error)
NewQueryStringParams creates at new QueryString from the given definition string
func (*QueryStringParams) GetParamForKey ¶
func (q *QueryStringParams) GetParamForKey(key string) *QSParameter
GetParamForKey searches for the param with the given key in the QueryString. If non is found nil is returned.
type Registry ¶
type Registry struct { Files Files Service *Service RootFile *File Messages Messages Enums Enums Package string }
The Registry is the root for registering the Types found in the protobuf structures from the compiler
func New ¶
func New(r *pluginpb.CodeGeneratorRequest) *Registry
New createsa new Registry that will read all the information neede from the given CodeGeneratorRequest
type Service ¶
type Service struct { Type *descriptorpb.ServiceDescriptorProto Registry *Registry File *File Package string GoPackage string Name string Imports []string BaseURI string Methods Methods Comment string Index int TargetPackage string Version string }
Service wraps a ServiceDescriptorProto with additions for code Generation
func (*Service) GetMappedMethods ¶
GetMappedMethods returns all the Methods of the currenct service that have a MethodMap extension Only those with a MethodMap extension will be exposed on the REST interface
func (*Service) HasServiceMapExtension ¶
func (*Service) RegisterMethod ¶
func (s *Service) RegisterMethod(method *descriptorpb.MethodDescriptorProto)
func (*Service) ServiceType ¶
ServiceType returns the name of the GRPC service, which will be used by the REST endpoints.
type SortedParsedQueryString ¶
type SortedParsedQueryString []QueryStringKV