Host defines a server host. A single server may define multiple hosts. Each host lists the set of URIs that identify it. The Host expression is leveraged by the example generator to produce the service and client commands. It is also consumed by the OpenAPI specification generator to initialize the
(name string, fn func())
| 115 | // }) |
| 116 | // }) |
| 117 | func Host(name string, fn func()) { |
| 118 | s, ok := eval.Current().(*expr.ServerExpr) |
| 119 | if !ok { |
| 120 | eval.IncompatibleDSL() |
| 121 | return |
| 122 | } |
| 123 | host := &expr.HostExpr{ |
| 124 | Name: name, |
| 125 | ServerName: s.Name, |
| 126 | Variables: &expr.AttributeExpr{Type: &expr.Object{}}, |
| 127 | } |
| 128 | eval.Execute(fn, host) |
| 129 | s.Hosts = append(s.Hosts, host) |
| 130 | } |
| 131 | |
| 132 | // URI defines a server host URI. A single host may define multiple URIs. The |
| 133 | // supported schemes are 'http', 'https', 'grpc' and 'grpcs' where 'grpcs' |