/
design.go
51 lines (46 loc) · 1.1 KB
/
design.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package design
import (
. "goa.design/goa/dsl"
cors "goa.design/plugins/cors/dsl"
)
var _ = API("calc", func() {
Title("CORS Example Calc API")
Description("This API demonstrates the use of the goa CORS plugin")
cors.Origin("http://127.0.0.1", func() {
cors.Headers("X-Shared-Secret")
cors.Methods("GET", "POST")
cors.Expose("X-Time")
cors.MaxAge(600)
cors.Credentials()
})
})
var _ = Service("calc", func() {
Description("The calc service exposes public endpoints that defines CORS policy.")
cors.Origin("/.*localhost.*/", func() {
cors.Methods("GET", "POST")
cors.Expose("X-Time", "X-Api-Version")
cors.MaxAge(100)
})
Method("add", func() {
Description("Add adds up the two integer parameters and returns the results.")
Payload(func() {
Attribute("a", Int, func() {
Description("Left operand")
Example(1)
})
Attribute("b", Int, func() {
Description("Right operand")
Example(2)
})
Required("a", "b")
})
Result(Int, func() {
Description("Result of addition")
Example(3)
})
HTTP(func() {
GET("/add/{a}/{b}")
Response(StatusOK)
})
})
})