示例#1
0
文件: main.go 项目: pomkine/weasel
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()
}
示例#2
0
文件: main.go 项目: pomkine/weasel
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()
}