* stats: refactor: move HTTP handlers to stats/

DNS module passes additional parameters to Stats module.
This allows Stats to handle HTTP requests by itself - completely removing
 all stats-related code from outside.
This commit is contained in:
Simon Zolin
2019-09-25 15:36:09 +03:00
parent 407917241a
commit bbb5413331
9 changed files with 162 additions and 126 deletions

View File

@@ -569,14 +569,11 @@ func registerControlHandlers() {
registerRewritesHandlers()
RegisterBlockedServicesHandlers()
RegisterQueryLogHandlers()
RegisterStatsHandlers()
RegisterAuthHandlers()
http.HandleFunc("/dns-query", postInstall(handleDOH))
}
type httpHandlerType func(http.ResponseWriter, *http.Request)
func httpRegister(method string, url string, handler httpHandlerType) {
func httpRegister(method string, url string, handler func(http.ResponseWriter, *http.Request)) {
http.Handle(url, postInstallHandler(optionalAuthHandler(gziphandler.GzipHandler(ensureHandler(method, handler)))))
}