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

	configuration = conf

	if err != nil {
		logger.LogE(err)
	}
}
Esempio 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)
}
Esempio 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)
	}
}