-
Notifications
You must be signed in to change notification settings - Fork 0
/
service.go
55 lines (45 loc) · 1.08 KB
/
service.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
package frontend
import (
"flag"
"github.com/aukbit/pluto"
"github.com/aukbit/pluto/auth"
"github.com/aukbit/pluto/examples/auth/frontend/views"
"github.com/aukbit/pluto/server"
"github.com/aukbit/pluto/server/router"
)
var (
target string
httpPort string
)
func init() {
flag.StringVar(&target, "target", "127.0.0.1:65081", "auth backend address")
flag.StringVar(&httpPort, "http_port", ":8089", "auth frontend http port")
flag.Parse()
}
// Run runs auth frontend service
func Run() error {
// Define handlers
mux := router.New()
mux.POST("/authenticate", frontend.PostHandler)
// define http server
srv := server.New(
server.Name("api"),
server.Addr(httpPort),
server.Mux(mux),
)
// Define grpc Client
clt := auth.NewClientAuth(target)
// Define Pluto service
s := pluto.New(
pluto.Name("auth_frontend"),
pluto.Description("Authentication service is responsible to parse all json data to internal services"),
pluto.Servers(srv),
pluto.Clients(clt),
pluto.HealthAddr(":9093"),
)
// Run service
if err := s.Run(); err != nil {
return err
}
return nil
}