parser

package
v1.7.13 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FieldGoType

func FieldGoType(g *protogen.GeneratedFile, field *protogen.Field) (goType []any, pointer bool)

FieldGoType returns the Go type used for a field.

If it returns pointer=true, the struct field is a pointer to the type.

func FindField

func FindField(name string, inMessage *protogen.Message) *protogen.Field

func FullFieldName

func FullFieldName(fields []*protogen.Field) string

Types

type Endpoint

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

func (*Endpoint) Body

func (e *Endpoint) Body() string

func (*Endpoint) DescName

func (e *Endpoint) DescName() string

func (*Endpoint) FullName

func (e *Endpoint) FullName() string

func (*Endpoint) HttpRule

func (e *Endpoint) HttpRule() *annotations.HttpRule

func (*Endpoint) Input

func (e *Endpoint) Input() *protogen.Message

func (*Endpoint) InputGoIdent

func (e *Endpoint) InputGoIdent() protogen.GoIdent

func (*Endpoint) IsStreaming

func (e *Endpoint) IsStreaming() bool

func (*Endpoint) Method

func (e *Endpoint) Method() string

func (*Endpoint) Name

func (e *Endpoint) Name() string

func (*Endpoint) Output

func (e *Endpoint) Output() *protogen.Message

func (*Endpoint) OutputGoIdent

func (e *Endpoint) OutputGoIdent() protogen.GoIdent

func (*Endpoint) ParseParameters

func (e *Endpoint) ParseParameters() (*protogen.Message, *protogen.Field, []*protogen.Field, []*protogen.Field, error)

func (*Endpoint) Path

func (e *Endpoint) Path() string

func (*Endpoint) PathParameters

func (e *Endpoint) PathParameters() ([]string, error)

func (*Endpoint) Pattern

func (e *Endpoint) Pattern() *Pattern

func (*Endpoint) ResponseBody

func (e *Endpoint) ResponseBody() string

func (*Endpoint) SetHttpRule

func (e *Endpoint) SetHttpRule()

func (*Endpoint) SetPattern

func (e *Endpoint) SetPattern(pattern *Pattern)

func (*Endpoint) Unexported

func (e *Endpoint) Unexported(s string) string

type Pattern

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

A Pattern is something that can be matched against an HTTP request. It has an optional method, an optional host, and a path.

func ParsePattern

func ParsePattern(s string) (_ *Pattern, err error)

parsePattern parses a string into a Pattern. The string's syntax is

[METHOD] [HOST]/[PATH]

where:

  • METHOD is an HTTP method
  • HOST is a hostname
  • PATH consists of slash-separated segments, where each segment is either a literal or a wildcard of the form "{name}", "{name...}", or "{$}".

METHOD, HOST and PATH are all optional; that is, the string can be "/". If METHOD is present, it must be followed by a single space. Wildcard names must be valid Go identifiers. The "{$}" and "{name...}" wildcard must occur at the end of PATH. PATH may end with a '/'. Wildcard names in a path must be distinct.

func (*Pattern) String

func (p *Pattern) String() string

type Segment

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

A Segment is a pattern piece that matches one or more path segments, or a trailing slash.

If wild is false, it matches a literal Segment, or, if s == "/", a trailing slash. Examples:

"a" => Segment{s: "a"}
"/{$}" => Segment{s: "/"}

If wild is true and multi is false, it matches a single path Segment. Example:

"{x}" => Segment{s: "x", wild: true}

If both wild and multi are true, it matches all remaining path segments. Example:

"{rest...}" => Segment{s: "rest", wild: true, multi: true}

type Service

type Service struct {
	ProtoService *protogen.Service
	Endpoints    []*Endpoint
}

func NewServices

func NewServices(file *protogen.File) ([]*Service, error)

func (*Service) AppendRouteName

func (s *Service) AppendRouteName() string

func (*Service) ClientName

func (s *Service) ClientName() string

func (*Service) FullName

func (s *Service) FullName() string

func (*Service) HandlerName

func (s *Service) HandlerName() string

func (*Service) Name

func (s *Service) Name() string

func (*Service) NewClientName

func (s *Service) NewClientName() string

func (*Service) RequestDecoderName

func (s *Service) RequestDecoderName() string

func (*Service) RequestEncoderName

func (s *Service) RequestEncoderName() string

func (*Service) ResponseDecoderName

func (s *Service) ResponseDecoderName() string

func (*Service) ResponseEncoderName

func (s *Service) ResponseEncoderName() string

func (*Service) ServiceName

func (s *Service) ServiceName() string

func (*Service) Unexported

func (s *Service) Unexported(name string) string

Jump to

Keyboard shortcuts

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