package design import ( "github.com/goadesign/goa/design/apidsl" ) var _ = apidsl.API("example", func() { apidsl.GET("/", func() { apidsl.Response(200) }) })
package design import ( "github.com/goadesign/goa/design/apidsl" ) var _ = apidsl.API("example", func() { apidsl.POST("/users", func() { apidsl.Request(func() { apidsl.Attribute("username", apidsl.String, "Username") }) apidsl.Response(201, func() { apidsl.Headers(func() { apidsl.Header("Location", apidsl.String, "Location of new resource") }) apidsl.Status(201) apidsl.Entity(func() { apidsl.Attribute("id", apidsl.Integer, "Identifier of new user") }) }) }) })This code defines a POST endpoint at "/users" that expects a request with a "username" attribute. The endpoint responds with a 201 status code, a "Location" header, and an entity that includes an "id" attribute. Package library: The goa.design APIDefinition package is a part of the goa.design library, which provides a complete suite of tools for designing and developing APIs in Golang. Other packages in the library include goa.design/plugins/cors for handling cross-origin resource sharing (CORS) and goa.design/plugins/security for adding security middleware to endpoints.