func Handler()

in pkg/mock/asglifecycle/asglifecycle.go [48:67]


func Handler(res http.ResponseWriter, req *http.Request) {
	if c.MockIPCount >= 0 {
		// req.RemoteAddr is formatted as IP:port
		requestIP := strings.Split(req.RemoteAddr, ":")[0]
		if !eligibleIPs[requestIP] {
			if len(eligibleIPs) < c.MockIPCount {
				eligibleIPs[requestIP] = true
			} else {
				log.Printf("Requesting IP %s is not eligible for ASG Lifecycle State because the max number of IPs configured (%d) has been reached.\n", requestIP, c.MockIPCount)
				server.ReturnNotFoundResponse(res)
				return
			}
		}
	}

	switch req.URL.Path {
	case targetLifeCycleStatePath:
		handleASGTargetLifecycleState(res, req)
	}
}