Ejemplo n.º 1
0
func initConfig() {
	parser := config.JsonConfigParser{}
	conf, err := parser.Parse()

	configuration = conf

	if err != nil {
		logger.LogE(err)
	}
}
Ejemplo n.º 2
0
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)
}
Ejemplo n.º 3
0
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)
	}
}