Slide 12
Slide 12 text
API
色々書ける。けど、実は必須ではないので書かなくともよい。
package design
import (
. "goa.design/goa/v3/dsl"
)
// API describes the global properties of the API server.
var _ = API("calc", func() {
Title("Calculator Service")
Description("HTTP service for multiplying numbers, a goa teaser")
// Server describes a single process listening for client requests. The DSL
// defines the set of services that the server hosts as well as hosts details.
Server("calc", func() {
Description("calc hosts the Calculator Service.")
// List the services hosted by this server.
Services("calc")
// List the Hosts and their transport URLs.
Host("development", func() {
Description("Development hosts.")
// Transport specific URLs, supported schemes are:
// 'http', 'https', 'grpc' and 'grpcs' with the respective default
// ports: 80, 443, 8080, 8443.
URI("http://localhost:8000/calc")
URI("grpc://localhost:8080")
})
Host("production", func() {
Description("Production hosts.")
// URIs can be parameterized using {param} notation.
URI("https://{version}.goa.design/calc")
URI("grpcs://{version}.goa.design")
// Variable describes a URI variable.
Variable("version", String, "API version", func() {
// URL parameters must have a default value and/or an
// enum validation.
Default("v1")
})
})
})
})