-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.go
43 lines (33 loc) · 1.01 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
package main
import (
"net/http"
"github.com/micro/go-micro/client"
log "github.com/sirupsen/logrus"
"github.com/kstkn/hypersomnia/config"
"github.com/kstkn/hypersomnia/handler"
"github.com/kstkn/hypersomnia/micro"
)
//go:generate go run templates.go
var conf config.Config
func init() {
conf = config.NewConfig()
log.SetLevel(conf.LogLevel)
log.Debugf("configuration %+v", conf)
localClient := micro.NewLocalClient(
client.NewClient(client.Registry(conf.GetRegistry())),
conf.GetRegistry(),
conf.RpcRequestTimeout,
)
webClient := micro.NewMultiWebClient(conf.Environments)
http.Handle("/", handler.NewIndexHandler(localClient, webClient))
http.Handle("/service", handler.NewServiceHandler(localClient, webClient))
http.Handle("/services", handler.NewServicesHandler(localClient, webClient))
http.Handle("/call", handler.NewCallHandler(localClient, webClient))
}
func main() {
log.Info("starting web server on " + conf.Addr)
s := &http.Server{
Addr: conf.Addr,
}
log.Fatal(s.ListenAndServe())
}