internal

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2022 License: GPL-3.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LeftDelim  = "{{"
	RightDelim = "}}"
)
View Source
const (
	HTTPAnyMethod    = "ANY"
	HTTPGETMethod    = http.MethodGet
	HTTPPOSTMethod   = http.MethodPost
	HTTPDELETEMethod = http.MethodDelete
	HTTPPATCHMethod  = http.MethodPatch
	HTTPPUTMethod    = http.MethodPut
)

Variables

This section is empty.

Functions

func CopyHttpRequest

func CopyHttpRequest(r *http.Request) *http.Request

func GenerateDefaultStringTemplate

func GenerateDefaultStringTemplate(templateText string) (string, error)

func GenerateDefaultTemplate

func GenerateDefaultTemplate(templateText string) ([]byte, error)

func GenerateTemplate

func GenerateTemplate(templateText string, templateData interface{}, params map[string]interface{}) ([]byte, error)

func MustGetJBody

func MustGetJBody(c *gin.Context) string

func NewHttpRequestWithHeader added in v0.0.3

func NewHttpRequestWithHeader(ctx context.Context, method string, url string, body []byte, header map[string]string) ([]byte, error)

func NewHttpServer

func NewHttpServer(desc *httpServerDescriptor) *httpServer

func ParamValue

func ParamValue(param map[string]struct{}, jBody string) (map[string]interface{}, error)

func ParametersFromStr

func ParametersFromStr(str string, regExpr *regexp.Regexp) map[string]struct{}

func ParseProtoFile

func ParseProtoFile(importPath []string, filePath []string) ([]*desc.FileDescriptor, error)

func ParseProtoFileFromProtoset

func ParseProtoFileFromProtoset(protosetPath string) (*desc.FileDescriptor, error)

func ParseServerMethodsFromFileDescriptor

func ParseServerMethodsFromFileDescriptor(fileDesc ...*desc.FileDescriptor) *gRpcServer

func ParseServerMethodsFromProto

func ParseServerMethodsFromProto(importPath []string, filePath []string) (*gRpcServer, error)

func ParseServerMethodsFromProtoset

func ParseServerMethodsFromProtoset(filePath string) (*gRpcServer, error)

func ReplaceParamValue added in v0.0.3

func ReplaceParamValue(param map[string]struct{}, jBody string, originStr string) (string, error)

func SetOutputFunc

func SetOutputFunc(schemaList GrpcServerDescriptionList, gRpcServ *gRpcServer) error

func ValidateGrpcServiceInputAndOutput

func ValidateGrpcServiceInputAndOutput(schemaList GrpcServerDescriptionList, gRpcServ *gRpcServer) error

func ValuableBoolExpression

func ValuableBoolExpression(expressionStr string) (bool, error)

Types

type CallbackDescription

type CallbackDescription struct {
	CallbackDescriptionBase
	Request []CallbackRequest `yaml:"request" json:"request"`
}

func (*CallbackDescription) UnmarshalYAML

func (s *CallbackDescription) UnmarshalYAML(unmarshal func(interface{}) error) error

type CallbackDescriptionBase

type CallbackDescriptionBase struct {
	Kind ServerKind `yaml:"kind" json:"kind"`
}

type CallbackRequest

type CallbackRequest interface {
	MakRequest() error
}

type GrpcMethodDescription

type GrpcMethodDescription struct {
	Name            string                           `yaml:"name" json:"name"`
	DefaultResponse string                           `yaml:"defaultResponse" json:"defaultResponse"`
	DefaultMetaData map[string]string                `yaml:"defaultMetaData"`
	Conditions      ResponseConditionDescriptionList `yaml:"conditions" json:"conditions"`
	Parameters      map[string]string                `yaml:"-" json:"-"`
	HttpCallback    HttpCallbackDescriptionList      `yaml:"httpCallback"`
}

func (*GrpcMethodDescription) Validate

func (m *GrpcMethodDescription) Validate() error

type GrpcMethodDescriptionList

type GrpcMethodDescriptionList []*GrpcMethodDescription

func (GrpcMethodDescriptionList) Validate

func (m GrpcMethodDescriptionList) Validate() error

type GrpcServerDescription

type GrpcServerDescription struct {
	Name    string                    `yaml:"name" json:"name"`
	Methods GrpcMethodDescriptionList `yaml:"methods" json:"methods"`
}

func (*GrpcServerDescription) GetMethod

func (g *GrpcServerDescription) GetMethod(methodName string) (*GrpcMethodDescription, error)

func (*GrpcServerDescription) Validate

func (g *GrpcServerDescription) Validate() error

type GrpcServerDescriptionList

type GrpcServerDescriptionList []*GrpcServerDescription

func (GrpcServerDescriptionList) GetMethod

func (s GrpcServerDescriptionList) GetMethod(servName string, methodName string) (*GrpcMethodDescription, error)

func (GrpcServerDescriptionList) Validate

func (s GrpcServerDescriptionList) Validate() error

type HttpCallbackDescription

type HttpCallbackDescription struct {
	Method    string            `yaml:"method"`
	URL       string            `yaml:"url" json:"url"`
	Header    map[string]string `yaml:"header" json:"header"`
	Body      string            `yaml:"body" json:"body"`
	DelayTime int64             `yaml:"delayTime" json:"delayTime"`
	// contains filtered or unexported fields
}

func (*HttpCallbackDescription) Validate added in v0.0.3

func (h *HttpCallbackDescription) Validate() error

type HttpCallbackDescriptionList added in v0.0.3

type HttpCallbackDescriptionList []*HttpCallbackDescription

func (HttpCallbackDescriptionList) Validate added in v0.0.3

func (c HttpCallbackDescriptionList) Validate() error

type MockGrpcResponse

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

type ResponseConditionDescription

type ResponseConditionDescription struct {
	Condition          string              `yaml:"condition" json:"condition"`
	Response           string              `yaml:"response" json:"response"`
	Parameters         map[string]struct{} `yaml:"-" json:"-"`
	ResponseParameters map[string]struct{} `yaml:"-" json:"-"`
}

type ResponseConditionDescriptionList

type ResponseConditionDescriptionList []*ResponseConditionDescription

type SchemaDescription

type SchemaDescription struct {
	SchemaDescriptionBase
	Server ServerDescriptionInterface `yaml:"servers" json:"servers"`
}

func LoadSchemaFromYaml

func LoadSchemaFromYaml(filePath string) (*SchemaDescription, error)

func (*SchemaDescription) Unmarshal

func (s *SchemaDescription) Unmarshal(d []byte) error

func (*SchemaDescription) UnmarshalYAML

func (s *SchemaDescription) UnmarshalYAML(unmarshal func(interface{}) error) error

func (SchemaDescription) Validate

func (s SchemaDescription) Validate() error

func (SchemaDescription) ValidateAndStartServer

func (s SchemaDescription) ValidateAndStartServer() error

type SchemaDescriptionBase

type SchemaDescriptionBase struct {
	Kind ServerKind `yaml:"kind" json:"kind"`
	Port int        `yaml:"port" json:"port"`
}

type ServerDescriptionInterface

type ServerDescriptionInterface interface {
	Validate() error
	StartServer(port int) error
}

type ServerKind

type ServerKind string
const (
	GRPC ServerKind = "grpc"
	HTTP ServerKind = "http"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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