Documentation
¶
Overview ¶
Package example contains code generation algorithms to produce an example server and client implementation for the transports defined in the design.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Servers = make(ServersData)
Servers holds the server data needed to generate the example service and client. It is computed from the Server expressions in the service design.
Functions ¶
func CLIFiles ¶
CLIFiles returns example client tool main implementation for each server expression in the design.
Types ¶
type Data ¶
type Data struct {
// Name is the server name.
Name string
// Description is the server description.
Description string
// Services is the list of services supported by the server.
Services []string
// Schemes is the list of supported schemes by the server.
Schemes []string
// Hosts is the list of hosts defined in the server.
Hosts []*HostData
// Variables is the list of URL parameters defined in every host.
Variables []*VariableData
// Transports is the list of transports defined in the server.
Transports []*TransportData
// Dir is the directory name for the generated client and server examples.
Dir string
}
Data contains the data about a single server.
func (*Data) AvailableHosts ¶
AvailableHosts returns a list of available host names.
func (*Data) DefaultHost ¶
DefaultHost returns the first host defined in the server expression.
func (*Data) DefaultTransport ¶
func (s *Data) DefaultTransport() *TransportData
DefaultTransport returns the default transport for the given server. If multiple transports are defined, HTTP transport is used as the default.
type HostData ¶
type HostData struct {
// Name is the host name.
Name string
// Description is the host description.
Description string
// Schemes is the list of schemes supported by the host. It is computed
// from the URI expressions defined in the Host.
// Possible values are http, https, grpc, grpcs.
Schemes []string
// URIs is the list of URLs defined in the host.
URIs []*URIData
// Variables is the list of URL parameters.
Variables []*VariableData
}
HostData contains the data about a single host in a server.
type ServersData ¶
ServersData holds the server data from the service design indexed by server name.
func (ServersData) Get ¶
func (d ServersData) Get(svr *expr.ServerExpr) *Data
Get returns the server data for the given server expression. It builds the server data if the server name does not exist in the map.
type Transport ¶
type Transport string
Transport is a type for supported goa transports.
const ( // TransportHTTP is the HTTP transport. TransportHTTP Transport = "http" // TransportGRPC is the gRPC transport. TransportGRPC = "grpc" )
type TransportData ¶
type TransportData struct {
// Type is the transport type.
Type Transport
// Name is the transport name.
Name string
// Services is the list of services supported by the transport.
Services []string
}
TransportData contains the data about a transport (http or grpc).
type URIData ¶
type URIData struct {
// URL is the underlying URL.
URL string
// Scheme is the URL scheme.
Scheme string
// Port is the default port for the scheme.
// http - 80, https - 443, grpc - 8080, grpcs - 8443
Port string
// Transport is the transport type for the URL.
Transport *TransportData
}
URIData contains the data about a URL.
type VariableData ¶
type VariableData struct {
// Name is the name of the variable.
Name string
// Description is the variable description.
Description string
// VarName is the variable name used in generating flag variables.
VarName string
// DefaultValue is the default value for the variable. It is set to the
// default value defined in the variable attribute if exists, or else set
// to the first value in the enum expression.
DefaultValue string
// Values is the list of allowed values for the variable. The values can
// only be primitives. We convert the primitives into string type so that
// we could use them to replace the URL variables in the example
// generation.
Values []string
}
VariableData contains the data about a URL variable.
Source Files
¶
- docs.go
- example_cli.go
- example_server.go
- server_data.go