package main import ( "bufio" "net" "net/http" "devel.mephi.ru/dyokunev/xml2jsond/stream" xj "github.com/basgys/goxml2json" ) func main() { http.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) { json, err := xj.Convert(req.Body) if err != nil { return } w.Write([]byte(json.String())) }) go func() {http.ListenAndServe(":60080", nil)}() go func() { ln, err := net.Listen("tcp", ":60081") if err != nil { panic(err) } for { conn, err := ln.Accept() if err != nil { panic(err) } go func(conn net.Conn) { defer func() {conn.Close()} () connReader := bufio.NewReader(conn) json, err := xj.Convert(connReader) if err != nil { return } conn.Write([]byte(json.String())) }(conn) } }() { ln, err := net.Listen("tcp", ":60082") if err != nil { panic(err) } for { conn, err := ln.Accept() if err != nil { panic(err) } go func(conn net.Conn) { defer func() {conn.Close()} () stream.Run(conn, conn) }(conn) } } }