private void HandleRequestForClockWebPage(HttpListenerRequest request, HttpListenerResponse response) { if (_optionsService.Options.IsWebClockEnabled) { _apiThrottler.CheckRateLimit(ApiRequestType.ClockPage, request); ClockWebPageController controller = new ClockWebPageController(); controller.HandleRequestForWebPage(response); } }
private void HandleDeleteTimersApi(HttpListenerRequest request, HttpListenerResponse response) { CheckSegmentLength(request, 5); _apiThrottler.CheckRateLimit(ApiRequestType.TimerControlStop, request); if (int.TryParse(request.Url.Segments[4], out var talkId)) { WriteResponse(response, _timerService.StopTalkTimerFromApi(talkId)); } }
private void HandleApiVersionRequest(HttpListenerRequest request, HttpListenerResponse response) { CheckMethodGet(request); _apiThrottler.CheckRateLimit(ApiRequestType.Version, request); var v = new ApiVersion { LowVersion = OldestSupportedApiVer, HighVersion = CurrentApiVer }; WriteResponse(response, v); }
public void Handler( HttpListenerRequest request, HttpListenerResponse response, int oldestSupportedApiVersion, int currentApiVersion) { CheckMethodGet(request); CheckSegmentLength(request, 4); _apiThrottler.CheckRateLimit(ApiRequestType.System, request); // segments: "/" "api/" "v1/" "system/" WriteResponse(response, GetSystemData(oldestSupportedApiVersion, currentApiVersion)); }
public void Handler(HttpListenerRequest request, HttpListenerResponse response) { CheckMethodPost(request); CheckSegmentLength(request, 4); _apiThrottler.CheckRateLimit(ApiRequestType.Bell, request); var responseData = new BellResponseData(); // segments: "/" "api/" "v1/" "bell/" if (!_bellService.IsPlaying) { responseData.Success = true; _bellService.Play(_optionsService.Options.BellVolumePercent); } else { responseData.Success = false; } WriteResponse(response, responseData); }
public void Handler(HttpListenerRequest request, HttpListenerResponse response) { CheckMethodGet(request); CheckSegmentLength(request, 4); _apiThrottler.CheckRateLimit(ApiRequestType.DateTime, request); // segments: "/" "api/" "v1/" "datetime/" // system clock var dt = DateTime.Now; var lt = new LocalTime { Year = dt.Year, Month = dt.Month, Day = dt.Day, Hour = dt.Hour, Min = dt.Minute, Second = dt.Second }; WriteResponse(response, lt); }