-
Notifications
You must be signed in to change notification settings - Fork 34
/
design.go
69 lines (64 loc) · 1.8 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package design
import (
. "goa.design/goa/v3/dsl"
_ "goa.design/plugins/v3/goakit"
)
var _ = API("fetcher", func() {
Title("The goakit example upstream service")
Description("Fetcher is a service that makes GET requests to arbitrary URLs and stores the results in the downstream 'archiver' service.")
})
var _ = Service("fetcher", func() {
Method("fetch", func() {
Description("Fetch makes a GET request to the given URL and stores the results in the archiver service which must be running or the request fails")
Payload(func() {
Attribute("url", String, "URL to be fetched", func() {
Format("uri")
})
Required("url")
})
Result(FetchMedia)
Error("bad_request")
Error("internal_error")
HTTP(func() {
GET("fetch/{*url}")
Response(StatusOK)
Response("bad_request", StatusBadRequest)
Response("internal_error", StatusInternalServerError)
})
})
})
var FetchMedia = ResultType("application/vnd.goa.fetch", func() {
Description("FetchResponse contains the HTTP status code returned by the fetched service and the href to the archived results in the archiver service")
TypeName("FetchMedia")
Attributes(func() {
Attribute("status", Int, "HTTP status code returned by fetched service", func() {
Minimum(0)
Example(200)
})
Attribute("archive_href", String, "The href to the corresponding archive in the archiver service", func() {
Pattern("^/archive/[0-9]+$")
Example("/archive/1")
})
Required("status", "archive_href")
})
View("default", func() {
Attribute("status")
Attribute("archive_href")
})
})
var _ = Service("health", func() {
HTTP(func() {
Path("/health")
})
Method("show", func() {
Description("Health check endpoint")
Result(String)
HTTP(func() {
GET("/")
Response(func() {
Code(StatusOK)
ContentType("text/plain")
})
})
})
})