Commit b17d7d03 authored by Kirill Smelkov's avatar Kirill Smelkov

X move handler up to match python structure

parent e2306922
...@@ -12,6 +12,21 @@ import ( ...@@ -12,6 +12,21 @@ import (
"net/http" "net/http"
) )
func handler(w http.ResponseWriter, r *http.Request) {
xc := NewXClassifier()
path := r.URL.Path
for i := range path {
xc.nextChar(path[i])
}
fmt.Fprintf(w, "%s:\t%d\n%s:\t%d\n%s:\t%d\n%s:\t%d\ntotal:\t%d\n",
navytux, xc.nnavytux, nexedi, xc.nnexedi,
lab, xc.nlab, erp5, xc.nerp5,
xc.ntotal)
}
const ( const (
navytux = "navytux.spb.ru" navytux = "navytux.spb.ru"
nexedi = "www.nexedi.com" nexedi = "www.nexedi.com"
...@@ -69,20 +84,6 @@ func (xc *XClassifier) nextChar(ch byte) { ...@@ -69,20 +84,6 @@ func (xc *XClassifier) nextChar(ch byte) {
xc.ntotal += 1 xc.ntotal += 1
} }
func handler(w http.ResponseWriter, r *http.Request) {
xc := NewXClassifier()
path := r.URL.Path
for i := range path {
xc.nextChar(path[i])
}
fmt.Fprintf(w, "%s:\t%d\n%s:\t%d\n%s:\t%d\n%s:\t%d\ntotal:\t%d\n",
navytux, xc.nnavytux, nexedi, xc.nnexedi,
lab, xc.nlab, erp5, xc.nerp5,
xc.ntotal)
}
func main() { func main() {
http.HandleFunc("/", handler) http.HandleFunc("/", handler)
fmt.Println("Serving on :25000") fmt.Println("Serving on :25000")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment