Esempio n. 1
0
func main() {
	logger.Init(logger.Config{"server.log", true})
	client.ProxyCheckUrl = *checkProxyMSEndpoint + "/check/proxy"
	ps, err := db.New(*dbDir)
	if err != nil {
		logger.Errf("Creating proxy storage: %v", err)
		os.Exit(1)
	}

	s := checker.CheckerService{Ps: ps}
	s.Start()

	ms := microservice.Microservice{Addr: ":8000"}
	ms.RegEP(
		endpoint.Endpoint{
			Path:   "/proxylist/new",
			Method: "POST",
			EdpHandler: endpoint.Adapt(endpoint.EdpHandlerFunc(handleNewProxyList),
				mw.JsonConv(), mw.JsonHeaders(), db.ProxyStorageAdapter(ps)),
			ErrHandler: mw.DefaultJsonErrHandler{},
		},
	)
	ms.RegEP(
		endpoint.Endpoint{
			Path:   "/proxylist",
			Method: "GET",
			EdpHandler: endpoint.Adapt(endpoint.EdpHandlerFunc(handleProxyList),
				mw.JsonConv(), mw.JsonHeaders(), db.ProxyStorageAdapter(ps)),
			ErrHandler: mw.DefaultJsonErrHandler{},
		},
	)
	ms.Start()
}
Esempio n. 2
0
func main() {
	logger.Init(logger.Config{"server.log", true})
	ms := microservice.Microservice{Addr: ":6060"}
	ms.RegEP(
		endpoint.Endpoint{
			Path:   "/check/proxy",
			Method: "POST",
			EdpHandler: endpoint.Adapt(endpoint.EdpHandlerFunc(handleProxyCheck),
				mw.JsonConv(), mw.JsonHeaders()),
			ErrHandler: mw.DefaultJsonErrHandler{},
		},
	)
	ms.Start()
}