Skip to content

Commit

Permalink
Add schemes to API design
Browse files Browse the repository at this point in the history
  • Loading branch information
raphael committed Nov 15, 2015
1 parent 2688d50 commit 5c02ae4
Show file tree
Hide file tree
Showing 15 changed files with 632 additions and 848 deletions.
2 changes: 2 additions & 0 deletions design/definitions.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ type (
Description string // API description
// API hostname
Host string
// API URL schemes
Schemes []string
// Common base path to all API actions
BasePath string
// Common path parameters to all API actions
Expand Down
14 changes: 14 additions & 0 deletions design/dsl/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
// URL("doc URL")
// })
// Host("goa.design") // API hostname
// Schemes("http")
// BasePath("/base/:param") // Common base path to all API actions
// BaseParams(func() { // Common parameters to all API actions
// Param("param")
Expand Down Expand Up @@ -150,6 +151,19 @@ func Host(host string) {
}
}

// Schemes sets the API URL schemes.
func Schemes(vals ...string) {
if a, ok := apiDefinition(true); ok {
for _, v := range vals {
if v != "http" && v != "https" && v != "ws" && v != "wss" {
ReportError(`invalid scheme "%s", must be one of "http", "https", "ws" or "wss"`, v)
} else {
a.Schemes = append(a.Schemes, v)
}
}
}
}

// Contact sets the API contact information.
func Contact(dsl func()) {
if a, ok := apiDefinition(true); ok {
Expand Down
Loading

0 comments on commit 5c02ae4

Please sign in to comment.