Skip to content

Instantly share code, notes, and snippets.

@ikawaha
Created June 13, 2019 00:28
Show Gist options
  • Save ikawaha/7317274ea5bbf0dd2d51c22cf6240b28 to your computer and use it in GitHub Desktop.
Save ikawaha/7317274ea5bbf0dd2d51c22cf6240b28 to your computer and use it in GitHub Desktop.
package design
import (
. "goa.design/goa/v3/dsl"
cors "goa.design/plugins/v3/cors/dsl"
)
var _ = API("calc", func() {
Title("Calculator Service")
Description("Service for adding numbers, a Goa teaser")
Server("calc", func() {
Host("localhost", func() {
URI("http://localhost:8000")
URI("grpc://localhost:8080")
})
})
cors.Origin("/.*localhost.*/", func() {
cors.Headers("Content-Type", "api_key", "Authorization")
cors.Methods("GET", "POST", "DELETE", "PUT", "PATCH", "OPTIONS")
cors.MaxAge(600)
})
})
var _ = Service("calc", func() {
Description("The calc service performs operations on numbers.")
Method("add", func() {
Payload(func() {
Field(1, "a", Int, "Left operand")
Field(2, "b", Int, "Right operand")
Required("a", "b")
})
Result(Int)
HTTP(func() {
GET("/add/{a}/{b}")
})
GRPC(func() {
})
})
})
var _ = Service("calc2", func() {
Description("The calc service performs operations on numbers.")
Method("add2", func() {
Payload(func() {
Field(1, "a", Int, "Left operand")
Field(2, "b", Int, "Right operand")
Required("a", "b")
})
Result(Int)
HTTP(func() {
GET("/add2/{a}/{b}")
})
GRPC(func() {
})
})
})
var _ = Service("swagger", func(){
Files("/openapi.json", "./gen/http/openapi.json", func(){
Meta("swagger:generate", "false")
})
})
@ikawaha
Copy link
Author

ikawaha commented Jun 13, 2019

		{"server-hosting-service-with-file-server", ctestdata.ServerHostingServiceWithFileServerDSL, testdata.ServerHostingServiceWithFileServerHandlerCode},

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment