Skip to content

Instantly share code, notes, and snippets.

@shihanng
Last active April 18, 2017 03:42
Show Gist options
  • Save shihanng/d28e750844eb9508f575845bca09dadc to your computer and use it in GitHub Desktop.
Save shihanng/d28e750844eb9508f575845bca09dadc to your computer and use it in GitHub Desktop.
package design
import (
. "github.com/goadesign/goa/design"
. "github.com/goadesign/goa/design/apidsl"
)
var _ = API("users", func() {
Title("Users Management")
Scheme("http")
Host("localhost:8080")
})
var User = Type("user", func() {
Description("")
Attribute("email", String, "User's email address")
Attribute("name", String, "User's name")
Required("email", "name")
})
var UserMedia = MediaType("vnd.my.user", func() {
Reference(User)
Attributes(func() {
Attribute("email")
Attribute("name")
})
View("default", func() {
Attribute("email")
Attribute("name")
})
})
var _ = Resource("Users", func() {
BasePath("/users")
Action("add", func() {
Description("Register a new user")
Routing(POST("/add"))
Payload(User)
Response(Created)
})
Action("list", func() {
Description("List all users")
Routing(GET("/list"))
Response(OK, CollectionOf(UserMedia))
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment