MCPcopy Create free account
hub / github.com/goadesign/goa / defaultURI

Function defaultURI

http/codegen/openapi/v2/builder.go:104–122  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
104func 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.
125func addScopeDescription(scopes []*expr.ScopeExpr, sd *SecurityDefinition) {

Callers 1

NewV2Function · 0.85

Calls 2

URIStringMethod · 0.80
SchemeMethod · 0.45

Tested by

no test coverage detected