goa: github.com/raphael/goa/codegen/example Index | Files

package example

import "github.com/raphael/goa/codegen/example"

Package example contains code generation algorithms to produce an example server and client implementation for the transports defined in the design.


Package Files

docs.go example_cli.go example_server.go server_data.go


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.

func CLIFiles Uses

func CLIFiles(genpkg string, root *expr.RootExpr) []*codegen.File

CLIFiles returns example client tool main implementation for each server expression in the design.

func ServerFiles Uses

func ServerFiles(genpkg string, root *expr.RootExpr) []*codegen.File

ServerFiles returns an example server main implementation for every server expression in the service design.

type Data Uses

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 Uses

func (s *Data) AvailableHosts() []string

AvailableHosts returns a list of available host names.

func (*Data) DefaultHost Uses

func (s *Data) DefaultHost() *HostData

DefaultHost returns the first host defined in the server expression.

func (*Data) DefaultTransport Uses

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.

func (*Data) HasTransport Uses

func (s *Data) HasTransport(transport Transport) bool

HasTransport checks if the server supports the given transport.

type HostData Uses

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.

func (*HostData) DefaultURL Uses

func (h *HostData) DefaultURL(transport Transport) string

DefaultURL returns the first URL defined for the given transport in a host.

type ServersData Uses

type ServersData map[string]*Data

ServersData holds the server data from the service design indexed by server name.

func (ServersData) Get Uses

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 Uses

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 Uses

type TransportData struct {
    // Type is the transport type.
    Type Transport
    // Name is the transport name.
    Name string

TransportData contains the data about a transport (http or grpc).

type URIData Uses

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 Uses

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.

Package example imports 9 packages (graph). Updated 2019-11-02. Refresh now. Tools for package owners. This is a quick bug-fix fork (has fewer than three commits, and only during the week it was created).