DefaultServer returns a server expression that describes a server which exposes all the services in the design and listens on localhost port 80 for HTTP requests and port 8080 for gRPC requests.
()
| 149 | // exposes all the services in the design and listens on localhost port 80 for |
| 150 | // HTTP requests and port 8080 for gRPC requests. |
| 151 | func (a *APIExpr) DefaultServer() *ServerExpr { |
| 152 | svcs := make([]string, len(Root.Services)) |
| 153 | for i, svc := range Root.Services { |
| 154 | svcs[i] = svc.Name |
| 155 | } |
| 156 | return &ServerExpr{ |
| 157 | Name: a.Name, |
| 158 | Description: "Default server for " + a.Name, |
| 159 | Services: svcs, |
| 160 | Hosts: []*HostExpr{{ |
| 161 | Name: "localhost", |
| 162 | ServerName: a.Name, |
| 163 | URIs: []URIExpr{URIExpr("http://localhost:80"), URIExpr("grpc://localhost:8080")}, |
| 164 | }}, |
| 165 | } |
| 166 | } |
| 167 | |
| 168 | // EvalName is the qualified name of the expression. |
| 169 | func (a *APIExpr) EvalName() string { return "API " + a.Name } |