func initConfig() { parser := config.JsonConfigParser{} conf, err := parser.Parse() configuration = conf if err != nil { logger.LogE(err) } }
func initLocations() { var bufferLocations []*location.Location for _, v := range configuration.Locations { bufferLocation, err := location.InitLocation(v.Rule, v.Root) if err != nil { logger.LogE(err) } bufferLocations = append(bufferLocations, bufferLocation) } locationManager = location.InitLocationManager(bufferLocations) }
func main() { listenParams := fmt.Sprintf("%s:%d", configuration.Host, configuration.Port) logger.LogI("Server started on " + listenParams) for _, v := range closers { defer v.Close() } listener, err := net.Listen("tcp", listenParams) if err != nil { logger.LogE(err) } for { conn, err := listener.Accept() if err != nil { logger.LogE(err) } go handleConnection(conn) } }