Last active
April 18, 2017 03:42
-
-
Save shihanng/d28e750844eb9508f575845bca09dadc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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