-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
46 lines (36 loc) · 1.05 KB
/
main.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
//go:generate goagen bootstrap -d design
package main
import (
"flag"
"app"
// "github.com/jiuchen1986/Go-Microservice/app"
"github.com/goadesign/goa"
"github.com/goadesign/goa/middleware"
)
var delay int64 // The processing delay for this service
func init() {
const (
defaultDelay = 0
usage = "the processing delay for this service"
)
flag.Int64Var(&delay, "delay", defaultDelay, usage)
flag.Int64Var(&delay, "d", defaultDelay, usage + " (shorthand)")
}
func main() {
flag.Parse()
delay = delay * 1000000
// Create service
service := goa.New("TEST REST API")
// Mount middleware
service.Use(middleware.RequestID())
service.Use(middleware.LogRequest(true))
service.Use(middleware.ErrorHandler(service, true))
service.Use(middleware.Recover())
// Mount "Test Service" controller
c := NewTestServiceController(service, delay)
app.MountTestServiceController(service, c)
// Start service
if err := service.ListenAndServe(":8082"); err != nil {
service.LogError("startup", "err", err)
}
}