defaultURI returns the first URI defined in the host. It substitutes any URI parameters with their default values or the first item in their enum.
(h *expr.HostExpr)
| 102 | // defaultURI returns the first URI defined in the host. It substitutes any URI |
| 103 | // parameters with their default values or the first item in their enum. |
| 104 | func defaultURI(h *expr.HostExpr) string { |
| 105 | // Get the first URL expression in the host by default. |
| 106 | // Host expression must have at least one URI (validations would have failed |
| 107 | // otherwise). |
| 108 | uExpr := h.URIs[0] |
| 109 | // attempt to find the first HTTP/HTTPS URL |
| 110 | for _, ue := range h.URIs { |
| 111 | s := ue.Scheme() |
| 112 | if s == "http" || s == "https" { |
| 113 | uExpr = ue |
| 114 | break |
| 115 | } |
| 116 | } |
| 117 | uri, err := h.URIString(uExpr) |
| 118 | if err != nil { |
| 119 | panic(err) // should never hit this! |
| 120 | } |
| 121 | return uri |
| 122 | } |
| 123 | |
| 124 | // addScopeDescription generates and adds required scopes to the scheme's description. |
| 125 | func addScopeDescription(scopes []*expr.ScopeExpr, sd *SecurityDefinition) { |