/
api_definition.go
66 lines (63 loc) · 1.4 KB
/
api_definition.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
package design
import (
"os"
. "github.com/goadesign/goa/design"
. "github.com/goadesign/goa/design/apidsl"
. "github.com/pei0804/goa-stater/normal/design/constant"
_ "github.com/pei0804/goa-stater/normal/design/models"
_ "github.com/pei0804/goa-stater/normal/design/resource"
)
var _ = API("pei0804/goa-stater", func() {
Title("pei0804/goa-stater")
Description("pei0804/goa-stater")
Contact(func() {
Name("pei")
Email("peeeei0804@gmail.com")
URL("https://github.com/pei0804/goa-stater/issues")
})
License(func() {
Name("MIT")
URL("")
})
Docs(func() {
Description("wiki")
URL("")
})
Host(func() string {
switch os.Getenv("Op") {
case "develop":
return "localhost:8080"
case "staging":
return "staging.com"
case "production":
return "production.com"
}
return "localhost:8080"
}())
Scheme(func() string {
switch os.Getenv("Op") {
case "develop":
return "http"
case "staging":
return "https"
case "production":
return "https"
}
return "http"
}())
BasePath("/")
Trait(AdminUserTrait, func() {
Security(AdminAuth)
Response(Unauthorized, ErrorMedia)
Response(NotFound)
Response(BadRequest, ErrorMedia)
Response(InternalServerError, ErrorMedia)
})
Trait(GeneralUserTrait, func() {
Security(GeneralAuth)
Response(Unauthorized, ErrorMedia)
Response(NotFound)
Response(BadRequest, ErrorMedia)
Response(InternalServerError, ErrorMedia)
})
})